Q: Write a program that ask the user how many people participated in a survey. It then inputs the height of each of the people and then calculates the average height.
This how I did it but it calculates the average height wrong.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
int main()
{
float number;
float height;
float avarage;
cout << "Enter the number of people that participated in a survey: " << endl;
cin >> number;
height = number;
while (height != 0)
{
cout << "Enter the Height: " << endl;
cin >> height;
height += height;
}
avarage = height / number;
cout << "Avarage is height is: " << avarage << endl;
return 0;
}