Answer to Question #42007 in C++ for mohameed shab

Question #42007
)wtita a progeam(starting from #include) that repeatedly collect possitive from the user stopping when the user entars a negative number to zero a output the prouduct of all positive entries .a sample run should apper on the text below
enter a number 3
enter a number 10
enter a number 2
enter a number -213
the prouduct of all your possitive number is 60
1
Expert's answer
2015-06-01T05:12:29-0400
#include <iostream>
using namespace std;
int main () {
int number;
int sum = 0;
while (true) {
cout << "enter a number ";
cin >> number;
if ( number < 0 ) {
break;
}
sum += number;
}
cout << "the prouduct of all your possitive number is " << sum << endl;
}

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
APPROVED BY CLIENTS