Answer to Question #296660 in C++ for Anil

Question #296660

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.

1
Expert's answer
2022-02-11T11:02:40-0500
#include<iostream>

using namespace std;

int main()
{
	int value;
	double sum = 0;
	do
	{
		cout << "Please, enter a value: ";
		cin >> value;
		if (value != 0)
		{
			sum += value;
		}
	} while (value!=0);
	cout << "Sum of all entered elements are " << sum;
}	

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog