Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

5. Building upon the previous questions you will create a marking system for professors at UOIT. - Structs can be used the same as any

image text in transcribed
image text in transcribed
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)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Donald A. Carpenter Fred R. McFadden

1st Edition

8178088045, 978-8178088044

More Books

Students also viewed these Databases questions

Question

2. You seem to feel frustrated when Lee doesnt do his homework.

Answered: 1 week ago