0

Hi ;
I know how to solve the same problem if i have limit numbers ,but here i have n intergers .How can the compiler understanst me when i need n integers ,like this question:

Write a program that takes an n number of integers and calculates their average.
Using for or while loop!

3
Contributors
3
Replies
4
Views
9 Years
Discussion Span
Last Post by computer engW
0

you should create a loop which takes in a number with every pass, adds it to a total number and stores how many numbers where entered (how many passes the loop made)

Then you would need something to break out of the loop.

When you're out of the loop, calculate the average value and display it.

This is not a very difficult assignment if you understand how loops work.

Good luck!

0
cin >> n;

That will allow the user to input a number, if that's what you were looking for. If you need to know how to use loops, you should do a bit more studying. It isn't very hard, I promise!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.