Use an extra variable to keep track of the finds:
Code:
#include <stdio.h>
int main() /* the proper way */
{
int nos[4];
int a,f, total=0; /* our new variable */
for(a=0;a<=3;a++)
{
printf("Enter Numbers:");
scanf("%d",&nos[a]);
}
printf("\nEnter a Number to be Found:");
scanf("%d", &f);
for(a=0;a<=3;a++) if(nos[a]==f) total++;
if (total>0) printf("Number found %d times.\n",total);
else printf("\nNumber Not Found");
return 0;
}
You also had an overwrite in your last code, because you assign 2 elements to nos, then you count thru them 1,2,3! You actually overflow by 2, because the 2 elements of nos are numbered 0 and 1 (2 and 3 do not exist). Always remember the first element of an array is 0, not 1.
So here the numbers match up: nos has 4 elements and we count thru them 0, 1, 2, and 3.