I'm going to guess that you want just one answer from your search, not a bunch of -1's for instance.
Code:
#include <stdio.h>
int main (void)
{
float ary[8];
float input;
int numbers;
int x;
int match;
printf("Enter 8 floating point numbers: \n");
for (numbers = 0; numbers < 8; numbers++)
scanf("%f", &ary[numbers]);
printf("Enter the number to be searched: \n");
scanf("%f", &input);
for (x = 0, match = 0; x < 8; x++)
{
if (ary[x] == input)
{
match = x;
}
}
if(match > 0)
printf("Match found at index %d\n", x);
else
printf("-1. No match was found\n");
system ("pause");
return 0;
}
Something like the above change?
Note that this will only give you the last index number that matches, not all of the matching indexes. Do you want all the matching indexes?