CSC209H5 Midterm: CSC209H UTM Test Midterm12s Solution 281
Document Summary
123456789anwar patel: anwar patel completed 10 courses with cgpa: 3. 700000 completed 10 courses with cgpa: 3. 700000. Make changes by printing neatly directly on the code (or beside it) so that it will work as intended. The problem is not the math in the calculation. #include struct student { char id[9]; char name[20]; double cgpa; int courses; void print(struct student s) { printf("%s: %s completed %d courses with cgpa: %f\n", s. id, s. name, s. courses, s. cgpa); void complete_course(struct student s, double mark) { /* calculate the new cgpa by weighting the old cgpa appropriately */ double new_cgpa = ((s. cgpa * s. courses) + mark ) / (float) (s. courses + 1); s. cgpa = new_cgpa; s. courses++; int main() { /* anwar just got a 4. 0 in csc209! print(s1); return 0; Explain why or why not and any additional changes to the code that would be required. The above solution will not work correctly because the strncpy will not correctly add a null-terminator to the name.