#include <stdio.h> main() { FILE *infile, *outfile; char inbuffer[80], m; int nu
ID: 3631669 • Letter: #
Question
#include <stdio.h>main()
{
FILE *infile, *outfile;
char inbuffer[80], m;
int number, sum = 0;
if ( (infile = fopen("numbers.txt","r") ) == NULL) {
printf("Input file could not be opened ");
exit(1);
}
if ( (outfile = fopen("count.txt","a") ) == NULL) {
printf("Can't open outfile ");
exit(1);
}
while ( (fgets(inbuffer, 80, infile) ) != NULL ) {
sscanf(inbuffer, "%d", &number);
sum = sum + number;
}
fprintf(outfile, "The sum is %d ", sum);
if (fclose(infile) == EOF)
printf("Input file could not be closed ");
return 0;
}
modify the program above that used group-written modules to calculate the average of three values to read integers from a file instead of using input from the keyboard. The number of integers read is determined by the number of integers in the file.
You can use it to have it work using just three values and then implement a counter to count the number of integers input to calculate the average