OK here is my program
Code:
#include<stdio.h> /* fprint, fscanf, fclose, fopen definitions */
int main(void)
{
FILE *inp, /* input file pointer */
*outp; /* output file pointer */
int input_status, /* status of input */
score, /* current score */
largest, /* largest score */
smallest; /* smallest score */
int max=0; /* maximum score */
int min=0; /* minimum score */
/* open input and output files */
inp = fopen ( "scores.dat" , "r" );
outp = fopen ( "results.dat", "w" );
fprintf (outp, " Scores\n");
fprintf (outp, " ------\n");
input_status = fscanf ( inp, "%d", &score );
max = score;
min = score;
while ( input_status == 1 ){
fprintf ( outp, " %d\n", score);
if (max < score)
largest = score;
if (min > score)
smallest = score;
max = score++;
min += score;
input_status = fscanf ( inp, "%d", &score);
}
/* if ( input_status != 1)
{
fscanf ( inp, "%d", &score);
printf ( "\nError in input of %d", score);
} */
if (input_status != 1)
{
fscanf ( inp, "%d", &score);
fprintf( outp, "The highest score is %d\n", max);
fprintf( outp, "The lowest score is %d\n", min);
}
/* closes files */
fclose (inp);
fclose(outp);
return(0);
}
I want my output to display the largest and the smallest numbers. Now I know that this part
Code:
max = score++;
min += score;
is wrong. But I don't know what to put to get what I want?