Question: C Programming Topics: Pointers, Structure, C-Function The structure below represents information about students and their list of grades in all modules. typedef struct { char*

C Programming

C Programming Topics: Pointers, Structure, C-Function The structure below represents information about

students and their list of grades in all modules. typedef struct {

char* module; int grade; } module_grade; //module, e.g. "COMP1028" /umerical grade typedef

struct { unsigned int student_ID; char* student_name; module_grade* grades; unsigned int grades_len;

Topics: Pointers, Structure, C-Function The structure below represents information about students and their list of grades in all modules. typedef struct { char* module; int grade; } module_grade; //module, e.g. "COMP1028" /umerical grade typedef struct { unsigned int student_ID; char* student_name; module_grade* grades; unsigned int grades_len; } student; //array of grades //length of the array grades You are required to implement THREE functions for managing students' grades. a) Write a C function called create_student_list that takes a student name and a student ID and returns a pointer to a new_student. The grades of the new_student will be initialized to NULL and grade_len is set to 0. The definition of the function is: student* create_student_list (char* stu_name, int stu_id) { b) Write a C function search_grade that takes a pointer to a student and a module and returns the grade of the student for this module. If the array of grades is NULL or the module is not in the array of grades, the function shall return -1. The definition of the function is: int search_grade (student* s, char* module) { c) Write a C function adding_grade that takes a pointer to a student and a module grade and adds the grade to the student's array of grades. If student->grades already contain a similar module, the function does nothing. If student->grades==NULL, you need to create an array of length 1 and add the new grade into the array. If student->grades !=NULL, you need to increase the size of the array by ONE, and add new_grade into the new entry in the array of grades. The function shall return 1 if a grade is successfully added. Otherwise, the function shall return 0; this can be because the module is already there or malloc fails. The definition of the function is: int adding_grade (student* s, module_grade new_grade) {

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!