### Displaying frequencies of values entered

So I'm supposed to display the values entered by the user as well as the frequency of those numbers and I'm not so sure where to start. Can anyone help me out?

This is what I have so far
 ``1234567891011121314151617181920`` `````` int main() { const int SIZE = 100; int y[SIZE] = {}; int dup[SIZE] = {}; for (int i = 0; i <=100;++i){ cout << "Enter a value between 1-100 (Press -99 to stop): " << endl; cin >> y[i]; if (y[i] == -99) break; } cout << "The values entered are: " << endl; for (int i = 0; i < y[i];++i) cout<
It’s a good start, but your question is very vague. Usually people here ask about specific problem. You’d better try by your own and, if you get some error, ask again.
reusing the i is causing you problems here, i'll reproduce your code with the i's renamed and hopefully it will put you back on course.... Also note the fix in the end criteria for the second for loop.

 ``1234567891011121314151617181920`` `````` int main() { const int SIZE = 100; int y[SIZE] = {}; int dup[SIZE] = {}; int turn; for (turn = 0; turn <=100;++turn){ cout << "Enter a value between 1-100 (Press -99 to stop): " << endl; cin >> y[turn]; if (y[turn] == -99) break; } cout << "The values entered are: " << endl; for (int i = 0; y[i] != -99 ;++i) cout<

so that should successfully list all of the values that the user entered. now you just need to tally them up.

 ``1234`` ``````if (y[i] == -99) break; else dup[y[i]]++;``````

examine dup in the debugger, it should contains the count for all numbers entered.
Topic archived. No new replies allowed.