Count Number of Data

How can I count the number of data in array

Example:

In a class with 20 pupils the heights of the individual pupils, in centimeters, are:

175, 167, 160, 164, 183, 187, 188, 179, 176, 175,
169, 175, 176, 178, 165, 160, 173, 165, 187, 178

The program should read in all the numbers and make a table like this:


height number of pupils
160 2
164 1
165 2
167 1
... ...
... ...
188 1
If you sort the array, you'll get all equal values right next to each other. Then, a simple loop will be able to count the number of occurences.
I really new in c++
would you mind ti give me the code ?
Yes, I would mind.

This is most likely homework. If I give you working code, you will learn nothing and you'll never be able to solve basic problems like this one yourself. Instead, if you just spend 30 minutes thinking on it, the next time will be much easier.
Topic archived. No new replies allowed.