creating n integers.

I am a beginner at C++, and i need help for an exercise for my C++ book.
it asks to average n numbers.
But i dont know how to create n integers.
Could somebody please help :D Thanks xD
There are two ways to do this. One (the blue pill) is the easy way out, but yields worse results. The other (the red pill) is the proper way to do it that can be harder at first but yields better results once you understand it.

The Blue Pill:
http://cplusplus.com/doc/tutorial/arrays/

The Red Pill:
http://cplusplus.com/doc/tutorial/classes/
http://cplusplus.com/doc/tutorial/templates/
http://cplusplus.com/reference/stl/vector/

-Albatross
Last edited on
Ah. Thank you. I'll take a look at both.
patryk wrote:
it asks to average n numbers.

Most probably you won't need to declare n integers. You can just have a variable to hold the sum of the integers given by the user and a counter variable to know how many they are. Initialize sum and counter to zero, use a loop to get the data from the user and then divide sum by counter.
Topic archived. No new replies allowed.