I have my final exam for intro to programming in c this sunday and upon studying found two questions that confuse me. I would appreciate if someone could help me solve them, I think my answers are wrong.
Write a function called getGrades. The function that repeatedly prompts the user for positive integers until the user enters a negative value to stop. The function should return the average of these grades, the highest grade and the lowest grade.
Code:
double getGrades()
{
double average;
double i;
printf("Enter Grade");
scanf("%lf", &i);
}
Write a function called Get_Info that takes a pointer to a student structure, (That has three fields: char array called name, and int id, and a double gpa) as its only argument. The function prompts the user for the required information to fill the structure and stores it in the appropriate fields.
Code:
typedef struct{
int id;
double gpa;
char name[SIZE];
}student;
void Get_Info(student list[], int num)
{
int i;
for(i=0;i<num;i++)
{
printf("\nName:%s", list[i].name);
printf("\nGPA:%lf", list[i].gpa);
printf("\nID: %d\n", list[i].id);
}
}