Your first step is accepting input, which is done using the scanf() function:
scanf("%d", &number);
This means that you want scanf() to accept input, convert the input to a number, and store it in the memory at the address of number.
Use a for() loop, counting from 0 to 9, and an array of integers to hold the numbers. Then simply scanf("%d", &intarray[counter]);
The next step is a little tricky, but not very if you plan it out in advance.
Each integer can contain 256, 65,536 or 4,294,967,296 different numbers. Creating an array to hold the count of each of those numbers is a waste of RAM.
Instead, you'll want an "associative" array as follows:
int numcount[MAXNUM][2];
MAXNUM is 10, or the number of integers in the array you're checking. The second dimension, 2, consists of the number and its count.
Obviously, you'll want a way to keep track of how many integers you've stored in numcount. An int called numcountnuminitialized to 0 would be the fastest way.
Use a for() loop to iterate through the integers. If the integer does not exist in numcount, then set numcount[numcountnum][0] to the integer, set numcount[numcountnum][1] to 1, and increment numcountnum. Otherwise, if the integer exists, increase numcount[the integer index][1].
Once the for() loop is finished, display the results. The only thing you have left to figure out is the function that searches the numcount array for an integer, and returns its index (or -1 if it's not found).
Copyright © 2026 eLLeNow.com All Rights Reserved.