5. Building upon the previous questions you will create a marking system for professors at UOIT. - Structs can be used the same as any other data type in C, instead of having two arrays for the grades and student ids create a struct called grade that contains two integers: student_id and mark. - Create a function grade_students which takes the following arguments: a pointer to the grade struct called grades, and an integer num_students. The function returns void and does the following: - Opens the file grades.txt in write mode - Using the num_students parameter iterates through all of the grade structs pointed to by the grades parameter (remember arrays are pointers, you can treat pointers like arrays). - For each grade structure adds the mark member of the struct to a variable called sum that holds the sum of all student's grades. - For each grade structure write to the file grades.txt the student id and the mark on a single line. - After adding every student's mark to the sum variable, calculate the average (mean) and standard deviation, you will need to use
don't forget when you compile to add -Im - Write to the file grades.txt the average and standard deviation that you calculated. - Create two pointers, a character pointer professor, and a pointer for the grade struct you created and call it grades, it will hold an array of grade structures. - Using dynamic memory, use calloc to alloccate 256 characters for the professor pointer. - Prompts the professor for their name, and the number of students to mark. - Store the professor's name using the professor pointer and in an integer num_students the number of students to mark. question5_template.c - Notepad File Edit Format View Help Winclude #include #includemath.h> typedef struct int student id; int mark; } grades; void grade students(grades *ptr, int num_students ); int main(void) void grade students(grades *ptr , int num students ) FILE *fp=fopen("grades.txt","w"); int sum; int average; int sd; int varsum; for(int n ; nenum students; ++n) sun - sum + ptr[n].mark; fprintf(fp, "Student ad mark - %d In", (ptrun)->student_id, (ptrn)->mark); average- sumum_students; for(int n ; ncnun students; ++n) varsum - varsum + pow((ptr[n].mark - average), 2); sd - sqrt(varsumum_students); fprintf(fp,"average - Xd , standard diviation -%d", average, sd); fclose(fp)