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.
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);
}
Comments
Leave a comment