C Program to Store Information of a Student Using Structure

45

In this program, we create the structure to store the student information. Here we create a structured student using keyword struct.

Flowchart to Store Information of a Student Using Structure

Flowchart to Store Information of a Student Using Structure
Flowchart to Store Information of a Student Using Structure
#include <stdio.h>

struct student {
    char name[50];
    char standard[10];
    char batch[50];
    int student_id;
};

int main() {
    struct student s1;
    printf("Enter name:");
    scanf("%s", &s1.name);
    printf("Enter standard:");
    scanf("%s", &s1.standard);
    printf("Enter batch:");
    scanf("%s", &s1.batch);
    printf("Enter student id:");
    scanf("%d", &s1.student_id);
    printf("student Detail: ");
    printf("\n Name: %s", s1.name);
    printf("\n Standard: %s", s1.standard);
    printf("\n Batch: %s", s1.batch);
    printf("\n Id: %d", s1.student_id);
    getch();

}

The student structure has four members that are the name, standard, batch, and student_id. Here s1 is the structure variable used to store the information and display on the screen.

Output

Enter name:David
Enter standard:6
Enter batch:A
Enter student id:123
student Detail: 
 Name: David
 Standard: 6
 Batch: A
 Id: 123

Get real time updates directly on you device, subscribe now.

Subscribe to our newsletter
Subscribe to our newsletter
Sign up here to get the latest news, updates and special offers delivered directly to your inbox.
You can unsubscribe at any time
You might also like