C Program to Store Information of Students Using Structure

To understand this example, you should have the knowledge of following C programming topics:

In this program, a structure(student) is created which contains name, roll and marks as its data member. Then, an array of structure of 10 elements is created. Then, data(name, roll and marks) for 10 elements is asked to user and stored in array of structure. Finally, the data entered by user is displayed.

Source Code to Store Information of 10 students Using Structure

#include <stdio.h>
struct student{
    char name[50];
    int roll;
    float marks;
int main(){
    struct student s[10];
    int i;
    printf("Enter information of students:\n");
        printf("\nFor roll number %d\n",s[i].roll);
        printf("Enter name: ");
        printf("Enter marks: ");
    printf("Displaying information of students:\n\n");
     printf("\nInformation for roll number %d:\n",i+1);
     printf("Name: ");
     printf("Marks: %.1f",s[i].marks);
   return 0;


Enter information of students: 

For roll number 1
Enter name: Tom
Enter marks: 98

For roll number 2
Enter name: Jerry
Enter marks: 89
Displaying information of students:

Information for roll number 1:
Name: Tom
Marks: 98