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.
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.