Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a function called Get_Info that takes a pointer to a student structure, (t

ID: 3647519 • Letter: W

Question

Write a function called Get_Info that takes a pointer to a student structure, (that has three fields: char array called name, an 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.

Explanation / Answer

# include typedef struct{ char name[100]; int id; double gpa; }student; void Get_info(student *s) { int i=0; int finish=0; char ch; printf("Enter your id: "); scanf("%d",&(s->id)); printf("Enter your GPA: "); scanf("%lf",&(s->gpa)); printf("Enter your name: "); scanf("%c",&ch); while(finish==0) { scanf("%c",&(s->name)[i]); if((s->name)[i]==' ') { finish=1; (s->name)[i]=''; continue; } i++; } } int main() { student *s; Get_info(s); printf("%s %d %lf",s->name,s->id,s->gpa); }
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote