I am a newbie to all of this, trying to learn on my own. This is revised code that others had helped me with.
This code is STILL giving me some wrong output.
1. It gives the maxHeight but not the minHeight of the five students.
2. It does not give me the number of girls or number of boys.
3. It does not give me the average girl's height.
This is an update from prior code.
#include <iostream>
#include <fstream>
using namespace std;
int main ()
{
int height[5];
char gender[5];
int userNumber = 0;
int totalHeight = 0;
int maxHeight = 0;
int minHeight = 0;
int avg = 0;
cout << "The tallest student is " << maxHeight << " and the shortest student is " << minHeight << endl;
cout << "The average height of all students is " << avg << endl;
cout << "The number of female students is " << girls << endl;
cout << "The number of male students is " << boys << endl;
cout << "The average height of female students is " << favg << endl;
cout << "The student heights and genders you entered are: "<< endl;
for (int x = 0; x < 10; x = x + 1)
{
cout << height[x] << endl;
cout << gender[x] << endl;
}
You made another thread for the same problem, deleted the contents of the old one and still don't use [code] tags. That's a bit irritating..
1. you initialize minheight to 0 and no height is less than 0.
2. maybe you enter 'm' and check with 'M' ? also, where are girls, boys declared?
3. that comes from 2 and also because girls is probably an integer and integer division rounds down.