+ 2

Explain in Detail!

Code: #include <iostream> using namespace std; int main() { int num = 1; int number; int total = 0; while (num <= 5) { cin >> number; total += number; num++; } cout << total << endl; return 0; } what does total += number mean? what is its alternative(total += number)

4th Jun 2018, 3:09 PM
Sakaar Sen
Sakaar Sen - avatar
5 Respuestas
+ 14
while loops 5 time and every time it loop , it recieve one number from user , every time it recieve new number it sum "total" variable with new number and save it in total when loop ends it print total value
4th Jun 2018, 3:16 PM
AliR૯za
AliR૯za - avatar
+ 14
is this enough or need more explanation ?
4th Jun 2018, 3:17 PM
AliR૯za
AliR૯za - avatar
+ 14
it means total = total + number
4th Jun 2018, 3:31 PM
AliR૯za
AliR૯za - avatar
+ 13
it recieve 5 number & calculate them summation
4th Jun 2018, 3:12 PM
AliR૯za
AliR૯za - avatar
0
total +=number means what?
4th Jun 2018, 3:20 PM
Sakaar Sen
Sakaar Sen - avatar