Hello all. I am a beginning programmer, taking my first programming class in college this semester. I have a program that

it's supposed to:

first: read the data from an outside file, data1.dat and find the average of all the entries in column 3 when the number in column1=1, or ignore the row if column1=0

or

find the maximum value of column 3 if column2=1

find the minimum value of column 3 if column2=0

it has some problem in the code, and when asked, my professor could not determine what it is. I'm kind of at a loss on this one.

the program I wrote is as follows:

any help is GREATLY appreciated.Code:/* Homework 6 */ #include <stdio.h> #include <math.h> #define FILENAME "data1.dat" int main() { /* declare variables */ int points=0; int c1, c2; double c3, ave, max, min, sum=0.0; int flag0=0, flag1=0; FILE *list; /* open file */ list = fopen(FILENAME, "r"); /* read file */ while ((fscanf(list, "%i, %i, %lf", &c1, &c2, &c3)) == 3) { /* compute the average, minimum and maximum */ if (c1 == 1) { sum += c3; points++; if (c2 == 0) { if (flag0 == 0) flag0 = 1; min = c3; if (c3 < min) min = c3; } if (c2 == 1) { if (flag1 == 0) flag1 = 1; max = c3; if (c3 > max) max = c3; } } } /* compute ave */ ave=sum/points; /* print a summary */ printf("average value: %7.2f \n", ave); printf("maximum reading: %7.2f \n", max); printf("minimum reading: %7.2f \n", min); fclose(list); return 0; }