1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73

#include <iostream>
using namespace std;
int main ()
{
// Set four counters to zero that is,
// sum_greater_than_zero, num_greater_than_zero, sum_less_than_zero, num_less_than_zero.
int numb;
int sum_greater_than_zero = 0, num_greater_than_zero = 0, sum_less_than_zero = 0, num_less_than_zero = 0;
int positiveSum = 0, nonpositiveSum = 0, sum = 0;
int positiveAverage = 0, nonpositiveAverage = 0, average = 0;
// Use a for loop done 10 times:
for (int i = 0; i < 10; i++)
{
cout << "Please enter any number that you'd like. \n ";
cin >> numb;
cout << " The sum of all positive numbers: " << positiveSum << endl;
cout << " The average of positive numbers: " << positiveAverage << endl ;
cout << " The sum of nonpositive numbers: " << nonpositiveSum << endl ;
cout << " The average of nonpositive numbers: " << nonpositiveAverage << endl ;
cout << " The sum of all positive and nonpositive numbers: " << sum << endl;
cout << " The average of all numbers entered: " << average << endl;
// Average of numbers:
//(1, 2, 3, 4, 5, 6, 7, 8, 9, 10) =(1+2+3+4+5+6+7+8+9+10)/10=5.5
//
sum = (sum_greater_than_zero + sum_less_than_zero);
positiveAverage = (sum_greater_than_zero/ num_greater_than_zero);
nonpositiveAverage = (sum_less_than_zero/ num_less_than_zero);
average = ( sum/ 10 );
}
// Ask the user to enter values:
// that is, whole numbers.
// Use if else statement:
if (numb > 0)
{
sum_greater_than_zero += numb;
num_greater_than_zero ++;
}
else if (numb < 0)
{
sum_less_than_zero += numb;
num_less_than_zero ++;
}
cout << endl;
return 0;
}
 