19. write a C program to illustrate the use of nested structure


Program to illustrate the use of nested structure

Source Code:

#include<stdio.h>
struct student
{
char name[30];
struct dob
{
int date,year,month;
};
};
int main()
{
struct student s;
struct dob d;
printf("enter the name of the person: ");
gets(n.name);
printf("enter the dob dd-mm-yy: ");
scanf("%d %d %d",&d.date,&d.month,&d.year);
puts(n.name);
printf("%d - %d -%d",d.date,d.month,d.year);
}

Output:

enter the name of the person: Srinivas
Srinivas
enter the dob dd-mm-yy:
01-01-2022
 01-01-2022

No comments:

Post a Comment