0

while loop iteration

int num = 1; int number; int total = 1; while (num <= 5) { cin >> number; total=total+number; num++; } cout << total << endl; return 0; } can anybody explain it to me.

27th Feb 2017, 7:21 AM
kishan tiwari
kishan tiwari - avatar
1 Odpowiedź
+ 1
loop will run 5 times. each time it will ask for any number as Input and it will make sum of all the 5 entered numbers+1.
27th Feb 2017, 7:27 AM
Raj Kumar Chauhan
Raj Kumar Chauhan - avatar