Help to get out of this problem in C++.
Ha ha ha this problem was ___. What I say took my whole day....
Now it is right and fully working program...
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
|
#include <iostream>
using namespace std;
int main()
{
int num, count = 0, sum_positive = 0, post_n = 0, avr_post = 0;
int sum_negative = 0, neg_n = 0, avr_neg = 0, sum_all, avr_all;
cout << "Please enter ten whole numbers.\n";
cout << "Press return key after writing a number.\n";
cout << " \n";
do
{
cout << "Type your number\n";
cin >> num;
if (num > 0)
{
sum_positive = sum_positive + num;
post_n++;
}
else
{
sum_negative = sum_negative + num;
neg_n++;
}
count++;
} while (count <= 10 );
cout << " \n";
cout << "Sum of your positive numbers are " << sum_positive << endl;
if (sum_positive > 0)
{
avr_post = sum_positive/post_n;
}
cout << "Average of all positive numbers are " << avr_post << endl;
cout << " \n";
cout << "Sum of your negative numbers are " << sum_negative << endl;
avr_neg = sum_negative / neg_n;
cout << "Average of all negative numbers are " << avr_neg << endl;
cout << " \n";
sum_all = sum_positive + sum_negative;
cout << "Sum of your all whole numbers are " << sum_all;
if (sum_all> 0)
{
avr_all = sum_all/count;
}
cout << " \n";
cout << "The average of all numbers are " << avr_all;
}
|
Last edited on
Topic archived. No new replies allowed.