C program to read and display the information of a student using a nested structure

Complete program to read and display the information of a student using a nested structure

#include <stdio.h>
#include <conio.h>
int main()
{
	 struct DOB
{
 int day;
 int month;
 int year;
};
struct student
{
 int roll_no;
	 	 char name[100];
	 	 float fees;
	 	 struct DOB date;
};
struct student stud1;
	 clrscr();
	 printf("\n Enter the roll number : ");
	 scanf("%d", &stud1.roll_no);
	 printf("\n Enter the name : ");
	 scanf("%s", stud1.name);
	 printf("\n Enter the fees : ");
	 scanf("%f", &stud1.fees);
	 printf("\n Enter the DOB : ");
	 scanf("%d %d %d", &stud1.date.day, &stud1.date.month, &stud1.date.year);

 printf("\n ********STUDENT'S DETAILS *******");
	 printf("\n ROLL No. = %d", stud1.roll_no);
	 printf("\n NAME = %s", stud1.name);
	 printf("\n FEES = %f", stud1.fees);
	 printf("\n DOB = %d – %d – %d", stud1.date.day, stud1.date.month, stud1.date.year);
	 getch();
	 return 0;
}

Output

Enter the roll number : 01
Enter the name : Rahul
Enter the fees : 45000
Enter the DOB : 25 09 1991
********STUDENT’S DETAILS *******
ROLL No. = 01
NAME = Rahul
FEES = 45000.00
DOB = 25 – 09 – 1991

Leave a Comment