- 1

What do this code do? Please help

int num = 1; int number; int total = 0; while (num <= 5) { cin >> number; total += number; num++; } cout << total << endl;

2nd Oct 2017, 10:53 PM
Anas
3 Answers
+ 3
while (num <= 5): until num is greater than 5 cin >> number;: put an integer number in "number" variable total += number;: update "total" variable adding "number" value num++: increase num value adding 1
2nd Oct 2017, 11:32 PM
Andrea Simone Costa
Andrea Simone Costa - avatar
+ 2
Thank you :)
4th Oct 2017, 2:52 AM
Anas
0
I'm not a big pro at c++ but i believe you can find your answer at this website. w3schools.com, I learnt alot from them
2nd Oct 2017, 11:11 PM
mike
mike - avatar