Question: //average.c #include #include #define MAX_SIZE 20 /* maximum 20 digits in file */ #define MAX_LINE 6 /* maximum 4 digits (+ 1 for newline) for

 //average.c #include #include #define MAX_SIZE 20 /* maximum 20 digits in //average.c #include  #include  #define MAX_SIZE 20 /* maximum 20 digits in file */ #define MAX_LINE 6 /* maximum 4 digits (+ 1 for newline) for each number. fgets reads n-1 chars*/ void read_numbers(FILE* fp, int numbers[], int* size){ *size = 0; char line[MAX_LINE]; while(fgets(line, MAX_LINE , fp) != NULL){ numbers[(*size)++] = atoi(line); /ote that this is missing error checking } } double average(FILE* fp, char* fileName){ int size; int numbers[MAX_SIZE]; double sum = 0; read_numbers(fp, numbers, &size); for(int i = 0; i  "); exit(EXIT_FAILURE); } FILE* input; input=fopen(argv[1], "r"); if (input == NULL){ fprintf(stderr, "Problem opening file %s ", argv[1]); exit(EXIT_FAILURE); } double avg; avg = average(input, argv[1]); printf("The average is %g ", avg); return 0; } 

Use the gdb tool to find and fix the problem of the given program, average.c. It should output: The average is 864.5 ./average input.txt . Create a Makefile to compile the when run with the given program. input.txt file as Files that need to be on GitHub: corrected version of average.c (you can call it average_corrected.c) Makefile to compile the program Demo: Grading for this part is all or nothing Show your TA how you used gdb to debug the program Run make on the new program and show your TA that your program behaves correctly now

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!