Task 11
Task 11
Task 11
Aim:
To write a C program to get students details and display it using array of structure.
Algorithm:
Step 1: Start.
Step 2: Declare a structure named Student with attributes: name, id, and GPA.
Step 4: Read the values of the structure members for n students using a loop.
Step 6: Stop.
Program:
#include <stdio.h>
struct student
char name[50];
int id;
float GPA;
};
int main()
scanf("%d",&n);
printf("Name: ");
scanf("%s", s[i].name);
printf("id: ");
scanf("%d", &s[i].id);
scanf("%f", &s[i].GPA);
printf("\n");
printf("Student Information:\n");
printf("Name \t id \t GPA\n");
printf("%s\t%d\t%0.2f\n", s[i].name,s[i].id,s[i].GPA);
}
Sample output:
Enter the number of students: 3
Name: Alice
id: 101
Name: Bob
id: 102
Name: Charlie
id: 103
Student Information:
Name id GPA
Result:
Thus the C program for displaying student details using array of structure has been
successfully completed.