C Program to Create a Student Details Using Structure

In C programming, structures provide a way to group related data under a single name. Here’s an example of a C program that creates a structure for representing student details.

Program :

#include<stdio.h>
#include<conio.h>
#include<string.h>
struct student
{
int id,marks;
char name[50];
}
main()
{
struct student s1,s2,s3;
printf(“Enter Student’s’ Name :\n”);
printf(“Enter name : “);
gets(s1.name);
printf(“Enter name : “);
gets(s2.name);
printf(“Enter name : “);
gets(s3.name);
printf(“Enter Student’s’ Is :\n”);
printf(“Enter id : “);
scanf(“%d”,&s1.id);
printf(“Enter id : “);
scanf(“%d”,&s2.id);
printf(“Enter id : “);
scanf(“%d”,&s3.id);
printf(“Enter Student’s’ Marks :\n”);
printf(“Enter marks : “);
scanf(“%d”,&s1.marks);
printf(“Enter marks : “);
scanf(“%d”,&s2.marks);
printf(“Enter marks : “);
scanf(“%d”,&s3.marks);
printf(“\n–: First student :–\nName : %s\nId : %d\nMarks : %d”,s1.name,s1.id,s1.marks);
printf(“\n–: Second student :–\nName : %s\nId : %d\nMarks : %d”,s2.name,s2.id,s2.marks);
printf(“\n–: Third student :–\nName : %s\nId : %d\nMarks : %d”,s3.name,s3.id,s3.marks);
}

Output :

Leave a Comment

Your email address will not be published.

Shopping Basket
Verified by MonsterInsights