28/01/2023

Structure Program for Student Details in C | Code with Output

Write a Structure Program for Student Details in C or Write a Program to Store and Print the Roll No., Name, Age and Marks of a Student Using Structures. We have to create a Structure with Student Name, Roll No and Marks. Now the User has to Enter the Student details manually Ie. Student Name, Student Roll Number & Student Marks: At the end, 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. We have to write a program to store and print the roll no., name, age and marks of a student using structures. For IT professionals looking to take their careers to the next level, there is a selection of Cisco CCNA Certification that will help you do just that.

Structure Program for Student Details in C

Below is the C Program to Display Student Details Using Structure. In this solution, we are going to Store and Print the Name, Roll No, and Marks of a Student Using Structures in C Programming. I will give you an assignment to all of you, try to solve this problem by slightly modifying the below code. The program statement: write c program to store information of students (Roll no, Name, Branch and Year) using structure.

Structure Program for Student Details in C


#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;
}

C Program to Display Student Details Using Structure Output


C Program to Display Student Details Using Structure Output

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. C Program for Structure. Write a C program to display student details using structure.

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.

The Logic for C Program to Display Student Details Using Structure


Here we are Defining the Structure and the Data Types with Structure. structure program for student details in c to store the Student Name, Roll no, and Student Marks.

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 Student Information Using Structure

Related to Structure Program in C


Previous Post
Next Post

post written by:

Hi, I’m Ghanendra Yadav, SEO Expert, Professional Blogger, Programmer, and UI Developer. Get a Solution of More Than 500+ Programming Problems, and Practice All Programs in C, C++, and Java Languages. Get a Competitive Website Solution also Ie. Hackerrank Solutions and Geeksforgeeks Solutions. If You Are Interested to Learn a C Programming Language and You Don't Have Experience in Any Programming, You Should Start with a C Programming Language, Read: List of Format Specifiers in C.
Follow Me

0 Comments: