Question: Please modify my C program so it prints out the desired output correctly.( Do not just copy and paste my code as the answer, I

Please modify my C program so it prints out the desired output correctly.( Do not just copy and paste my code as the answer, I will downvote. The code needs to successfully output the desired output. )

Here are the program directions:

Please modify my C program so it prints out the desired outputHere is my program source code:

#include #include #include // Prototype declaration of functions void getGrades(int ROWS, int COLS, int grades[ROWS][COLS], char students[COLS][20]); void printGrades(int ROWS, int COLS, int grades[ROWS][COLS]); void getStudents(int COLS, char students[COLS][20]); void printStudents(int COLS, char students[COLS][20]); void calcGrades(int ROWS, int COLS, int grades[ROWS][COLS], char Fgrades[]); void printFinalGrades(int COLS, char Fgrades[]); // File pointer FILE *fptr; // main function definition int main(int argc, char** argv) { // To store number of students and number of assignments int stu = 0, assign = 0; // Opens the file in read mode // command line argument argv[1] contains the file name fptr = fopen(argv[1], "r"); // Checks if the file pointer is NULL then display the error message and stop if (fptr == NULL) { printf("Cannot open file %s ", argv[1]); exit(0); }// End of if condition // Reads number of students and number of assignments from file fscanf(fptr, "%d%d", &stu, &assign); printf(" Number of Students %d Number of Assignment = %d", stu, assign); // Matrix for student names char students[stu][20]; // Matrix for assignment marks int grades[assign][stu]; // Array for grade char final_grade[stu]; // Calls the functions to read data from file and calculate grade getStudents(stu, students); getGrades(assign, stu, grades, students); calcGrades(assign, stu, grades, final_grade); printf(" "); // Calls the function to display data printStudents(stu, students); printGrades(assign, stu, grades); printFinalGrades(stu, final_grade);

return 0; }// End of main function

// Function to display final grade of all the students void printFinalGrades(int COLS, char Fgrades[]) { int i = 0; // Loops till number of students for (i = 0; i = 90) // Assign grade as 'A' Fgrades[i] = 'A'; // Otherwise checks if average is greater than or equals to 80 else if (avg >= 80) // Assign grade as 'B' Fgrades[i] = 'B'; // Otherwise checks if average is greater than or equals to 70 else if (avg >= 70) // Assign grade as 'C' Fgrades[i] = 'C'; // Otherwise checks if average is greater than or equals to 60 else if (avg >= 60) // Assign grade as 'D' Fgrades[i] = 'D'; // Otherwise less than 60 else // Assign grade as 'F' Fgrades[i] = 'F'; }// End of for loop }// End of function // Function to display student names void printStudents(int COLS, char students[COLS][20]) { int i = 0; int numA = COLS; // Loops till number of columns for (i = 0; i You must take the input file name on the command line Be sure to have simple error checking to be sure the file exists and was successfully opened. The input file will have the following format: First line: Number of students Second Line: Number of assignments Third Line: Student Names, space delimited Fourth+ Line(s) Grades for all students for one assignment, space delimited. Example of input file format: 2 3 Joel Sophie 100 97 78 92 62 70 Requirements: - Your program must read input from a file in the proper format, NOT stdin - Your program should accept the filename from the commandline as shown in the example below Your program should be able to handle a file of any reasonable size. (I will not use excessively long student names, but there may be MANY students and grades.) Do not just make your arrays really large, you need to dynamically allocate them. Example: $ ./a.out infile.txt Joel 100 78 62 Sophie 97 92 70

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!