I am currently learning to code c++ by using the web page program, where I am doing a course. Now recently I got the following exercise:
Using a while or a do-while loop, make a program that asks the user to enter numbers and keeps adding them together until the user enters the number 0.
I wrote the following code in the hope that it would bring the exercise to conclusion:
#include <iostream>
using namespace std;
int main(void){
int sum = 0;
int number;
do
{
cout <<endl;
cin >> number;
sum += number;
cout << "The total so far is: " << sum << endl;
} while (number != 0);
cout << "The total is: " << sum << endl;
}
Yet when I run the code I get the following feedback from the website (there are two links one on the left and the other on the right):
Instructions of the exercise and Webpage feedback on the exercise
Can you tell me what am I doing wrong, alternatively can you propose an alternative solution then the code I provided? Thank you for any feedback!
cout <<endl;?