#include "p8.h" #define _CRT_SECURE_NO_WARNINGS #include void prompt_student_info(Student* out_student) { printf("Enter student ID: "); scanf("%d", &out_student->id); printf("Enter student first name: "); // Our array can only hold 16 characters including the null terminator, // so we can only read 15 non-null characters. Consider what happens // to any remaining characters if the user enters a string longer than // 15 characters. scanf("%15s", out_student->first_name); printf("Enter student last name: "); // Same as first name scanf("%15s", out_student->last_name); printf("Enter student GPA: "); scanf("%lf", &out_student->gpa); } void print_student(Student* student) { printf("%8d%16s%16s%8.2lf\n", student->id, student->first_name, student->last_name, student->gpa); } double compute_average_gpa(Student* students, int num_students) { double gpa_sum = 0.0; for (int i = 0; i < num_students; ++i) { gpa_sum += students[i].gpa; } return gpa_sum / num_students; }