Answer to Question #286108 in C++ for Gen

Question #286108

numbers: the positive, the zero, and the negative ones. Today, we shall pay attention only to the negative ones now. Make a loop that will accept random decimal/float numbers. When the user inputs 0, the loop will terminate and then output the sum of all negative numbers inputted in 3 decimal places.

1
Expert's answer
2022-01-09T13:06:12-0500
using namespace std;


/*
	numbers: the positive, the zero, and the negative ones. 
	Today, we shall pay attention only to the negative ones now. 
	Make a loop that will accept random decimal/float numbers. When the user inputs 0, 
	the loop will terminate and then output the sum of all negative numbers inputted in 3 decimal places.
*/


int main()
{
	float Num=0,Sum=0;
	do
	{
		cout<<"\n\tEnter a -ve Number: "; cin>>Num;
		Sum = Sum + Num;
	}while(Num<0);
	cout<<"\n\n\tSum = "<<Sum;
	return(0);
}

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