Question: (Using C programming) Write a program that will create an array of structures for storing student data. The program should read in 3 records containing

(Using C programming)

Write a program that will create an array of structures for storing student data. The program should read in 3 records containing student ID, name and GPA from the user, then store this information in array of structures. The program should then print out the records back to the user.

Here is a sample run of the program

enter student record 0 enter student name student1 enter student id 101 enter student gpa 2 enter student record 1 enter student name student2 enter student id 102 enter student gpa 3.8 enter student record 2 enter student name student4 enter student id 222 enter student gpa 3.1 Record 0:, student1 ID:101 GPA: 2.000000 Record 1:, student2 ID:102 GPA: 3.800000 Record 2:, student4 ID:222 GPA: 3.100000 Press any key to continue . . .

This is an example of how to create a structure of type student with the needed fields

struct student{ char name[20]; int id; double gpa; };

To create an array of structures of type student you can use the following

struct student studentarray[3];

To read in and print out the data use for loops for example

this would read in the data

for (i=0;i<3;i++) { printf("enter student record %d ",i); printf("enter student name "); scanf("%s",studentarray[i].name); // repeat for id and gpa }

// then use a similar for loop with printf statements to print out the data in the array

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!