Input numbers from the user and find the sum of all those input numbers until the user inputs zero. In other means, the loop should end when the user enters 0. Finally, display the sum of all those numbers entered by the user.
#include<iostream>
using namespace std;
int main()
{
double sum = 0;
int value;
do
{
cout << "Please, enter a value (0 - exit program): ";
cin >> value;
if (value == 0)break;
sum += value;
} while (true);
cout << "Sum of values is " << sum;
}
Comments
Leave a comment