0
Please tell how does each line get executed in it
int num = 1; int number; int total = 0; while (num <= 5) { cin >> number; total += number; num++; } cout << total << endl; return 0;
1 Respuesta
+ 6
You declare 3 integers, 'num' (which is equal 1), 'number' and 'total' (which is equal 0). In loop 'while' you ask for input and add it to total, then increase 'num' (it's used as counter for loop, it executes 5 times). Finally you output value of variable 'total'.