Answer to Question #295802 in C++ for Harsh

Question #295802

Input numbers from the user and find the product of all those input numbers until the user


inputs a negative number. In other means, the loop should end when the user enters a


negative number. Finally, display the product of all those positive numbers entered by the


user

1
Expert's answer
2022-02-09T15:58:37-0500
#include<iostream>

using namespace std;

int main()
{
	double value;
	double result = 1;
	do
	{
		cout << "Please, enter a value: ";
		cin >> value;
		if (value >=0)
		{
			result *= value;
		}
	} while (value>=0);
	cout << "Product of all numbers is " << result;	
}	

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