+ 1

int main() { int num = 1; int number; int total = 0; while (num <= 5) { cin >> number; total += number; num++; } cout << total << endl; return 0; } i neeed a very simple discussion please about the loop i don't understand anything

27th Sep 2016, 4:59 PM
Retag Tarek
Retag Tarek - avatar
3 Respuestas
+ 4
This loop asks for the user to input an integer 5 times and adds that integer to the total 5 times. I modified your code to display each step in the loop. See the link below, run the code, and enter 5 integers (each on a separate line) and then Submit to see it in action. https://code.sololearn.com/c5OSQrdRqrXj/#cpp
27th Sep 2016, 7:01 PM
Chris G
Chris G - avatar
0
MASSIVE thankkkss ❤❤
27th Sep 2016, 7:28 PM
Retag Tarek
Retag Tarek - avatar
0
good and comprehensive explanation thanks
30th Jan 2017, 5:09 AM
Jonathan Duwa
Jonathan Duwa - avatar