Write a program to demonstrate the use of nested structure.

#include<conio.h>
#include<stdio.h>
#include<stdlib.h>
int main()
{
struct bdate
{
int day,month,year;
};
struct student
{
int rno;
struct bdate d1;
char name[30];
}s1;
printf("\n---------Enter Students Details---------\n");
printf("Enter roll number:");
scanf("%d",&s1.rno);
printf("\nEnter birth date:");
scanf("%d",&s1.d1.day);
printf("\nEnter birth month:");
scanf("%d",&s1.d1.month);
printf("\nEnter birth year:");
scanf("%d",&s1.d1.year);
printf("\nEnter student name:");
scanf("\n%s",s1.name);
printf("\n%d",s1.rno);
printf("\n%d/%d/%d",s1.d1.day,s1.d1.month,s1.d1.year);
printf("\n%s",s1.name);
}

No comments:

Post a Comment