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

Expert's answer

#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;}
LATEST TUTORIALS
APPROVED BY CLIENTS