Help with count

+1 bryant anderson · November 3, 2014
i have a code so far that numbers entered by used and displays them in order i just cant figure out on how to search through the array and figure out how many times it was entered and display the count next to the number

Post a Reply


Oldest  Newest  Rating
0 H. P. Lovecraft · November 20, 2014
This can be one way to do it.
int i;
int key;

printf("Please enter a number you would like to search for: ");
scanf("%d", &key);

int array[] {11, 24, 343, 44, 325};
int found = 0; //keep track of how many we have found.
for (i = 0; i < 5; ++i) {
if (array == search) {

printf("%d is in the array %d time(s)\n", search, found);
0 You knees · November 3, 2014
can you post here your codes? 
0 Mayur Joshi · November 19, 2014
are you familiar with concept 'search algorithms'? try linear search on your scanned array. increment a variable each time element is found, display it, simple!!
if you want to sort those in order too, then learn sorting algorithms too like bubble sort.
  • 1



One of the most popular languages of all time.

Bucky Roberts Administrator