+ 1
Why does this code give me 10 as the output when I input 2?
#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; }
2 Antworten
+ 2
becuase after you input two, it adds 2 to your total 5 times.
you input 2
2+2+2+2+2=10
+ 1
Oh thank you! !