Question: Build a c program that reads information from a file and populates a student struct as a record in a linked list. typedef struct Node

Build a c program that reads information from a file and populates a student struct as a record in a linked list.

typedef struct Node { char name[20]; int age; float gpa; struct Node *next; } Student;

Student head;

Student *makeStudent(char name[], int age, double gpa) { //TODO }

void push(Student *s) { //TODO }

Student *findBestStudent() { //TODO }

float averageGPA() { //TODO

}

int main(int argc, char **argv) { if(argc != 2){ perror("Error "); return -1; }

head.next = NULL; FILE * file; file = fopen(argv[1] , "r"); if (!file){ perror("Error opening file "); return -1; }

char studentName[20]; int age; float gpa;

while (fscanf(file, "%s %d %f", studentName,&age,&gpa)!=EOF) { //TODO } fclose(file);

Student *bestStudent = findBestStudent(); printf("Highest GPA is: %s ", bestStudent->name); printf("Average GPA is: %.2f ", averageGPA());

return 0; }

file:

name age gpa

name age gpa

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!