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).
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
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
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
- C Program To Find Area And Circumference Of Circle
- C Program To Print ASCII Value Of Character
- C Program To Find Area Of Triangle
- C Program to Convert a person's name into Abbreviated
- C Program For Calculate A Simple Interest
- C Program To Find Greater No. Among given Three Number
- C Program For Find The Gross Salary Of An Employee
- C Program For Calculate Percentage Of 5 Subjects
- C Program For Converting Temperature Celsius Into Fahrenheit
- C Program To Display Size Of Different Datatype
0 Comments: