0
what is wrong with this?
#include <iostream> using namespace std; int main() { int number; int sum = 0; cout << "Enter a number: "; cin >> number; while (number >= 0) { sum += number; cout << "Enter a number: "; cin >> number; } cout << "\nThe sum is " << sum << endl; return 0; }
3 Answers
0
In the while loop, number has to be only >0, not equal.
0
Nothing wrong but loop won't stop until you input a negative number...
0
What do you expect
https://www.sololearn.com/discuss/955892/?ref=app