+ 3

How to make a c++ program for average of n numbers?

by using loop , while loop ,for loop etc

29th Sep 2017, 2:09 AM
Kartik Yadav
Kartik Yadav - avatar
7 Réponses
+ 9
I agree with Mr. Wells. But as an ad-hoc example play with this UGLY code to get the point. https://code.sololearn.com/cZPq0D7kg8g5
29th Sep 2017, 7:39 AM
Babak
Babak - avatar
+ 9
Don't worry Luka. He will figure out soon. ;)
29th Sep 2017, 7:54 AM
Babak
Babak - avatar
+ 4
Depends on how you get the numbers. If you are reading them from console or file, a while loop would be used to get them and you can sum their values and count how many during that loop. If they are predefined in an array, a for loop makes sense.
29th Sep 2017, 5:04 AM
John Wells
John Wells - avatar
+ 4
I could, but you need to learn how to do it yourself. It isn't that hard and, if you fail to get it to compile or run, post it here. I or someone else we explain how to fix it.
29th Sep 2017, 5:19 AM
John Wells
John Wells - avatar
+ 2
thanks sir,can u please send me the example
29th Sep 2017, 5:08 AM
Kartik Yadav
Kartik Yadav - avatar