VOOZH about

URL: https://www.geeksforgeeks.org/c/c-program-to-store-information-of-students-using-structure/

⇱ C Program to Store Information of Students Using Structure - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

C Program to Store Information of Students Using Structure

Last Updated : 12 Jul, 2025

Write a C program to store the information of Students using a Structure.

A structure is a user-defined data type in C that is used to create a data type that can be used to group items of possibly different types into a single type.

Example

Input: Name: John Doe, Roll Number: 101, Marks: 85
Name: Jane Smith, Roll Number: 102, Marks: 90

Output: Name: John Doe, Roll Number: 101, Marks: 85
Name: Jane Smith, Roll Number: 102, Marks: 90

Store Information of Students Using Structure in C

The student information generally contains the following data:

  • Name
  • Roll Number
  • Age
  • Total Marks

Structure to Store the Student Information

The structure should be able to store the above information for each student. So, we will create a data field for each of this information in the structure:

struct Student { 
int roll_number;
int age;
double total_marks;
char name[100]; 
};

We keep the character array name at the end because in case of buffer overflow, it does not overwrite the other variables' data in the structure.

Note: We can add more data fields in the structure according to our needs.

Implementation

Below is the C program to implement the structure to store the student information and print it:


Output
========================================
 Student Records 
========================================

Student 1:
 Name : Geeks1
 Roll Number : 1
 Age : 12
 Total Marks : 78.50

Student 2:
 Name : Geeks5
 Roll Number : 5
 Age : 10
 Total Marks : 56.84

Student 3:
 Name : Geeks2
 Roll Number : 2
 Age : 11
 Total Marks : 87.94

Student 4:
 Name : Geeks4
 Roll Number : 4
 Age : 12
 Total Marks : 89.78

Student 5:
 Name : Geeks3
 Roll Number : 3
 Age : 13
 Total Marks : 78.55
========================================
Comment
Article Tags: