This is a nested for loop. For example, if n == 16, then the loop will run 256 times. Is that what you want? If you want to go through each array, and each array is n==16 elements, then you probably want two loops, one after the other.
I think I have now sorted out the problem, by running the first loop to search for the first number and how many times it occurs. Then start the second one after that is complete. I am now having problems with the second number to search for though. It for some reason thinks that I am asking it to search for an 8. Any ideas on why this is occuring would be a big help, thanks.
Code:
#include<stdio.h>
int main(void)
{
int array[100], search, c, n, count = 0;
printf("Enter the number of elements in array.");
scanf("%d",&n);
printf ("There is %d numbers in the array.\n", n);
printf("Enter %d numbers\n", n);
for ( c = 0 ; c < n ; c++ )
scanf("%d",&array[c]);
printf("Enter the number to search\n");
scanf("%d",&search);
for ( c = 0 ; c < n ; c++ )
{
if ( array[c] == search )
{
printf("%d is present at location %d.\n", search, c+1);
count++;
}
}
if ( count == 0 )
printf("%d is not present in array.\n", search);
else
printf("%d is present %d times in array.\n", search, count);
if ( count == 2)
printf("One Pair.\n");
if ( count == 3)
printf("Three of a kind.\n");
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
int search2, c2, count2 = 0;
for ( c2 = 0 ; c2 < n ; c2++ )
scanf("%d",&array[c2]);
printf("Enter the number to search\n");
scanf("%d",&search2);
for ( c2 = 0 ; c2 < n ; c2++ )
{
if ( array[c2] == search2 )
{
printf("%d is present at location %d.\n", search2, c2+1);
count2++;
}
}
if ( count2 == 0 )
printf("%d is not present in array.\n", search2);
else
printf("%d is present %d times in array.\n", search2, count2);
if ( count2 == 2)
printf("One Pair.\n");
if ( count2 == 3)
printf("Three of a kind.\n");
return 0;
}