Array Help

Hello,

So i am trying to make a matching game in which there is an array which is scrambled. Is there a way to "check for a match" between two numbers in the array? For example, is what ever number in position 2 equal to what ever number in position 7?

Thank You,

Jack

if you want to check the whole array for matches, use a nested do loop like this

int nmbrMatches = 0;
int i, j;

for (i = 0; i < arraySize; i++)
{

for (j = i+1; j++; j < arraySize if( array == array[j]) nmbrMatches++;
}
That will find all matches. If you want to stop at the first match, use an exit.

That will find all matches.

     for (j = i+1; j++; j < arraySize   if( array == array[j])  nmbrMatches++;

If you're going to post code for an answer, shouldn't it at least compile?

That will find all matches. If you want to stop at the first match, use an exit.

If you want to exit the loop, without terminating the program, so you can actually use the data, use break;.