Write a program to store information (id, name) of Student using structure.


Source Code:

#include<stdio.h>
#include<conio.h>
struct student
{
	int no;
	char name[20];
};
void main()
{
	struct student s1,s2;  //structure variable’s
	clrscr();
	printf("Enter the Student id:");
	scanf("%d",&s1.no);
	flushall();
	printf("Enter the Student name:");
	gets(s1.name);

	printf("Student number is:%d \n",s1.no);
	printf("Student name is:%s \n \n ",s1.name);

	s2=s1;
	printf("Student number is:%d \n",s2.no);
	printf("Student name is:%s",s2.name);
	getch();
}

Output:

Enter the Student id: 101
Enter the Student name: Bhavesh Jain

Student number is: 101
Student name is: Bhavesh Jain
Student number is: 101
Student name is: Bhavesh Jain

Leave a Reply

Your email address will not be published. Required fields are marked *