WP Tuts Hub

WordPress Tutorials, Themes and Plugins Hub
Advertisement

Browse

  • Home
  • Categories
    • WordPress Troubleshooting
    • WordPress Tips and Tricks
    • SSH (Secure Shell)
    • WordPress Insights
    • WordPress Common Facts
    • WordPress Security
  • Series Tutorials
    • Advanced WordPress Topic
  • Privacy Policy
  • Terms of Use
  • Contact Me
  • About WP Tuts Hub
Home/C Programming/C Program to Store Multiple Student Records Using Structure and Pointer
C Programming
May 27, 2023

C Program to Store Multiple Student Records Using Structure and Pointer

  • Structure and Pointers in C
  • Structures in C Programming

This C program allows users to input the number of students, store student records as a structure using pointers and prints student information. In this C Program below we will store the student’s name, roll, age and CGPA and eventually print them on the console.

Program:

#include <stdio.h>
#include <stdlib.h>

struct Student
{
    char name[30];
    long int roll;
    int age;
    float cgpa;
};

int main()
{
    int num_students;
    struct Student *student;
    
    printf("Please enter the number of students: ");
    scanf("%d", &num_students);
    
    student = (struct Student *) malloc(num_students * sizeof(struct Student));
    
    for(int i=1; i<= num_students; i++) 
    {
        printf("Please enter student %d's info: \n", i);
        printf("Name: "); 
        scanf("%s", (student+i)->name);
        printf("Roll: "); 
        scanf("%ld", &(student+i)->roll);
        printf("Age: "); 
        scanf("%d", &(student+i)->age);
        printf("CGPA: "); 
        scanf("%f", &(student+i)->cgpa);
        printf("\n");
    }
    
    for(int i=1; i<= num_students; i++) 
    {
        printf("Student %d info: \n", i);
        printf("Name: %s\n", (student+i)->name);
        printf("Roll: %ld\n", (student+i)->roll);
        printf("Age: %d\n", (student+i)->age);
        printf("CGPA: %f\n", (student+i)->cgpa);
        printf("\n");
    }
    

    return 0;
}

Output:

Share this:

  • Share on X (Opens in new window) X
  • Share on Facebook (Opens in new window) Facebook
  • Share on LinkedIn (Opens in new window) LinkedIn
  • Share on WhatsApp (Opens in new window) WhatsApp
  • Share on Reddit (Opens in new window) Reddit
  • Email a link to a friend (Opens in new window) Email

Related

Previous Article Top WordPress Plugins to Secure Your Website in 2023
Next Article Implementing Custom Gutenberg Block Patterns with Dynamic Data

About the author

Md. Zubaer Ahammed
Md. Zubaer Ahammed

Md. Zubaer Ahammed is a senior full-stack developer building learning platforms and modern web systems with WordPress, Laravel, Python/Django, Vue, and React. More at https://zubaer.com/.

Related Posts

  • C Program to Store Multiple Student Records Using Array of Structures

Leave a Reply

Cancel reply

WP Tuts Hub

WordPress tutorials, themes, and plugins — written for builders.

  • Portfolio
  • Calorie Calculator Pro
  • Contact
  • About
  • Privacy
  • Terms

© 2026 WP Tuts Hub · Md. Zubaer Ahammed

Loading Comments...