Can someone please give me a hint as to what is wrong with my code? I cannot find the correct min and max of a file of integers.

insert
Code:

#include<stdio.h>
main()
{
int count = 0, sum = 0, num, min = 0, max = 0, avg;
FILE *fin, *fout;
fin = fopen("in.txt", "r");
fout = fopen ( "out.txt", "w");
while ( fscanf( fin, "%d", &num) != EOF){
count = count + 1;
sum = sum + num;
if (num>=max)
max=num;
else if (num<min)
min=num;
}
avg = sum/count;
fprintf(fout, "The number of integer values in the input file = %d\n", count);
fprintf(fout, "The minimum integer value in the input file = %d\n", min);
fprintf(fout, "The maximum integer value in the input file = %d\n", max);
fprintf(fout, "The average of the integer values in the input file = %d\n", avg);
fclose(fin);
fclose(fout);
}