05/03/2023

Structure Program For Student Details in C [Using Structure]

Write a program to store and print the roll no, name, age and marks of a student using structures. Structure program for student details in C Program. We can also simply say that the student mark list program in c uses structure or c program to store information of 10 students using structure. C program for student mark sheet using structure or c program using structures employee details or student mark list program in c using an array.

Structure Program For Student Details in C

Here we are storing a piece of student information using the structure we are taking input from Roll Number, Student Name, Student Age & Students Marks. But you can store multiple Student information as you want

Declare Structure Program For Student


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

Storing Student Details in Structure


{
	printf("\nRoll No: ");
	scanf("%d", &(s[i].roll));

	printf("Name: ");
	scanf("%s", s[i].name);

	printf("Age: ");
	scanf("%d", &(s[i].age));

	printf("Marks: ");
	scanf("%f", &(s[i].marks));
}

Displaying Student Stored Information


printf("\n\nDisplay Student Details:\n");

for (i = 0; i < n; i++)
{
	printf("\nRoll No: %d", s[i].roll);
	printf("\nName: %s", s[i].name);
	printf("\nAge: %d", s[i].age);
	printf("\nMarks: %f", s[i].marks);
	printf("\n\n");
}

Read: School Management System Project in Java With Source Code

Structure Program For Student Details in C Code


#include <stdio.h>

/*C Program to Store Information of 10(N) Students Using Structure*/

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

int main()
{
	int i, n;

	printf("\nEnter the Total Number Of Student: ");
	scanf("%d", &n);

	struct student s[n];

	printf("\nEnter Student Details (Enter Marks in Float Ie. 78.00):\n");

	for (i = 0; i < n; i++)
	{
		printf("\nEnter Student Roll No: ");
		scanf("%d", &(s[i].roll));

		printf("Enter Student Name: ");
		scanf("%s", s[i].name);

		printf("Enter Student Age: ");
		scanf("%d", &(s[i].age));

		printf("Enter Student Marks: ");
		scanf("%f", &(s[i].marks));
	}

	printf("\n\nDisplay Student Details:\n");

	for (i = 0; i < n; i++)
	{
		printf("\nStudent Roll No: %d", s[i].roll);
		printf("\nStudent Name: %s", s[i].name);
		printf("\nStudent Age: %d", s[i].age);
		printf("\nStudent Marks: %f", s[i].marks);
		printf("\n\n");
	}

	return 0;

}

What Is Structure


The structure is a user-defined data type in C which allows you to combine different data types to store a particular type of record. Structure helps to construct a complex data type in a more meaningful way. It is somewhat similar to an Array. The only difference is that array is used to store a collection of similar datatypes while a structure can store a collection of any type of data.

The structure is used to represent a record. Suppose you want to store a record of a Student which consists 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 define a new data type which is a collection of different type of data.

Structure Syntax

struct structure_name
{
//Statements
};

Structure Program For Student Details Output


Structure Program For Student Details Output

Similar to the Student Mark List Program


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: