0
int num = 1; int number; int total = 0; while (num <= 5) { cin >> number; total += number; num++; } cout << total << endl;
why is total=0😐?
5 Respostas
+ 3
First, there is a variable named number which is undefined, in line 2
You have to give number a value in order to add it in total
Otherwise, everytime total will result in 0
+ 1
ok
+ 1
Your code is true. In this app, you must type all of inputs(here ints) that the code wants by pressing enter key between.
0
why is it nessesery?
0
it's not?