60 526
Assignments Done
97,8%
Successfully Done
In April 2018

Answer to Question #47876 in C++ for Sakina

Question #47876
Write C++ program (if the number is positive, add the number to the variable positivesum; else, add the number to the variable negativesm?
Expert's answer
#include <iostream>
using namespace std;
//The main function
int main()
{
int a = 0;
int positivesum = 0;
int negativesum = 0;
while(1)
{
cout<<"Enter the number: “;
cin>>a;
if(a>0)
{
positivesum += a;
}
else
{
negativesum += a;
}
cout<<"Result: "<<sum<<endl;
}
//system("pause");
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 first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions