Write a C Program to Display Student Details Using Structure

Write a C Program to Display Student Details Using Structure. In this problem Statement, the User has to Enter the Student details manually Ie. Student Name, Student Roll Number & Student Marks: We have to print the Student details using the same respectful manner as Input using Structure (Name, Roll & Marks).

Before coding, we must know What is Structure, the Definition of Structure and the Syntax of Structure.

Write a C Program to Display Student Details Using Structure

What Is Structure

The structure is a user-defined data type in C. Structure represents a record. Suppose you want to store a student record of the student’s name, address, roll number and age. You can define a structure to hold this information.

Defining a Structure

struct keyword is used to define a structure. struct defines a new data type, a collection of different data types. Below is the Syntax of the Structure for the C Program to Display Student Details Using Structure.

Syntax of Structure

struct structure_name
{
//Statements
};

Below is the C Program to display the student’s name, roll number and marks.

C Program to Display Student Details Using Structure

#include <stdio.h>
struct student
{
    char name[50];
    int roll;
    float marks;
};
int main()
{
    struct student s;
    
 printf("Enter The Information of Students :\n\n");
    
 printf("Enter Name : ");
    scanf("%s",s.name);
    
 printf("Enter Roll No. : ");
    scanf("%d",&s.roll);
    
    printf("Enter marks : ");
    scanf("%f",&s.marks);
    
    printf("\nDisplaying Information\n");
    
 printf("Name: %s\n",s.name);
    printf("Roll: %d\n",s.roll);
    printf("Marks: %.2f\n",s.marks);
    return 0;
}

The output of the Program

The Output of the Program to Display Student Details Using Structure

The Logic for C Program for Storing the Student Details 

Here we are Defining the Structure and the Data Types with Structure.

struct student
{
    char name[50];
    int roll;
    float marks;
};

Here we are storing single student information ie, Student Name, Student Roll Number and Student Marks without using the FOR LOOP.

printf("Enter The Information of Students :\n\n");

scanf("%s",s.name);
scanf("%d",&s.roll);
scanf("%f",&s.marks); 

Here we are Printing the Student Details, Student Name, Student Roll Number and Student Marks without using any LOOPS.

printf("Name: %s\n",s.name);
printf("Roll: %d\n",s.roll);
printf("Marks: %.2f\n",s.marks);

Try This C Program To Store Multiple Students Information of Using Structure

Related to Structure Program in C

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.