Average Calculating program (New to this Forum)

closed account (13CjNwbp)
This is a homework problem, but I am stuck and looking for advice. The program is supposed give the average of the inputted values. It is also supposed to output the number of positive/negative numbers. Any help would be greatly appreciated, thank you in advance!

#include <iostream>

using namespace std;

int main()
{
cout << "Entering 0 will terminate the sequence of input values." << endl;
cout << "Enter a number: ";
float input;

float count = 1;
float sum = input;
float average = input;
int pos_nums = 0;
int neg_nums = 0;

while (input != 0)
{
cout << "Enter a number: ";
cin >> input;
{

average = sum/count;

if (input > 0) pos_nums++;

else (input < 0) neg_nums++;

}
}

cout << "Number of positive values: " << pos_nums << endl;
cout << "Number of negative values: " << neg_nums << endl;
cout << "The average of all entered values: " << average << endl;

return 0;
}
closed account (LNboLyTq)
Hi,
Don't know why your account is closed, but you are definitely calculating the 'average' the wrong way.
Try moving it outside the for loop.
Do that and let we know.
Topic archived. No new replies allowed.