Have first a look to 'Solution 2'. It is much easier and universal and in general better ;)
This is your task to solve to learn c.
Therefore I will not give you the solution, but a hint.
Instanciate two arrays of integers, both with the size N.
Let's name them:
Values
Counts
Values
will hold the numbers you need to evaluate.
Loop over
Values
and count the corresponding number in
Counts
. Something like:
countIx= Values[valueIx] - 1;
Counts[countIx]= Counts[countIx] + 1;
After all that you can loop over
Counts
and e.g. show how many time a number occured in
Values
.
Hint: What is fundamental here is that the indices of the array Count have a unique relationship to the values in Values. Try to understand the relationship, it has to do with the '-1' mentioned above.
[Edit]
Important: Be aware, this solution works only because of the restriction that the numbers to evaluate need to be in the range 1...N.
I hope it gives you an idea.