Get all semester notes for Computer Engineering here.

C Program to store and display information of five students using structure

C program to store and display the details of five students using structure

C Program to store and display information of five students using structure

We use a special datatype called structure to store data of the students and access the members anywhere with s[i].variable .

Code: 

#include<stdio.h>
struct students{
        char name[20];
        int rollNo;
        int age;
    }stu[5];
 int main(){
    printf("Enter the information of students");
    for(int i = 0;i<5;i++){
        printf("\nEnter the information of roll no %d\n",i+1);
        stu[i].rollNo = i+1;
        printf("Enter Name of student: ");
        scanf("%s",stu[i].name);
        printf("\nEnter age of the student: ");
        scanf("%d",&stu[i].age);
    }
    printf("Roll no \t Name \t\t Age\n");
    for(int i =0; i<10;i++){
        printf("=======");
    }
    for(int i = 0;i<5;i++){
        printf("\n%d \t\t %s \t\t %d",stu[i].rollNo,stu[i].name,stu[i].age);
    }
}{codeBox}

 

This is the C program to store details of  5 students using structure.

Also Read: 

I am into computer science.

Post a Comment

Feel free to comment.