Hello everyone,
I am having the user input a integer. Then from that input, search an array with static elements. Then return(print) how many times the users int was found in array. I am using a for loop to iterate through the array, but can not get it to count how many times it appears. This is the rough version I have so far:
I know the last printf is wrong, but I am running out of ideas.Code:#include <stdio.h> #define SIZE 20 int n[]={25,68,15,35,84,56,8,52,27,7,53,15,8,42,32,1,5,8,41,23}; int c; int t; int main(void) { printf("enter numer to search?"); scanf("%d",&t); for (c=0;c<SIZE;c++) { if (t==n[c]) printf ("yes"); else { printf ("no"); } printf ("the value %d was found %d times in array",t,n[c]); } }
Thanks in advance for any suggestions.
Brad



LinkBack URL
About LinkBacks



