Minimum Value wont output

Hello, would anyone know why my code keeps outputting 0 for the min? Everything works except the minimum.

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

#include<iostream>
#include<fstream>
using namespace std;

void InputOutput(char inputfile[100], char outputfile[100])
{

	ifstream eds;
	ofstream pds;

	eds.open(inputfile);//opening input file

	char first_Name[100], last_Name[100];
	float grades = 0.0;
	float max = 0.0;
	float min = 0.0;
	int count = 0;
	float average = 0;


	while (!eds.eof())
	{

		eds >> first_Name >> last_Name >> grades;

		count++;

		
		if (grades > max)
			max = grades;
		else if (grades < min)
			min = grades;
		
		average += grades;
	}

	eds.close();

	average /= count;

	pds.open(outputfile);

	pds << "The highest grade in the class is:" << max << endl;
	pds << "The lowest grade in the class is: " << min << endl;
	pds << "The class average is: " << average << endl;
	cout << "The highest grade in the class is:" << max << endl;
	cout << "The lowest grade in the class is: " << min << endl;
	cout << "The class average is: " << average << endl;

	pds.close();

}

int main()
{
	char inputfile[100];
	char outputfile[100];

	cout << "Enter the input file: ";
	cin >> inputfile;
	cout << "Enter the ouput file: ";
	cin >> outputfile;

	InputOutput(inputfile, outputfile);
	system("pause");
	return 0;
}
Topic archived. No new replies allowed.