Actually try this:
#include<stdio.h>
#define NUM_PTS 15
const int array[NUM_PTS] = {78, 23, 67, 31, 79, 3, 25, 9, 65, 3, 18, 80, 16, 2, 90};
main()
{
int N, x;
printf("Enter N: ");
scanf("%d", &N);
for (x=0; x>=NUM_PTS; x++) {
if (N == array[x]) {
printf("%d is in array position %d", N, x);
break;
}
}
if (x == NUM_PTS)
printf("%d does NOT appear in the array", N);
} //end main
Why do I move the array outside of the main routine? That is to prevent too much use of stack space, but it could have been declared within main too, it's scope would only be within main however. Why do I const it? That way the array is populated and created at compile time rather than empty memory being created on the stack, and then populated with values from an invisible const source the compiler creates at compile time. This means you would have both a variable array and a const array using up memory, and there has to be invisible code to copy these constants to this new memory location on the stack. My method will use only one const source, wont have to initialize data, and run faster.
Also why do I use #define NUM_PTS 15? Since 15 was used more than once and refers to an array size, it should be written this way NO MATTER WHAT! Get used to this practice. If not you will wind up increasing the size of your array and forgetting to change at least one corresponding value in code.
If you removed break from my code, it would be able to report all instances of a match and it's position, but then the "NOT appear" would always report as TRUE. You would have to make some small additional changes to add that support, like a flag.
Probably more than you wanted, and normally I don't do student's homework for them, but people already gave it away.
-LS