Write a C program to define a structure named DOB, which contains name, day, month and year. Using the concept of nested structures display your name and date of birth.
Program Code:
#include<stdio.h>
#include<string.h>
void main()
{
struct person
{
charfname[20];
charlname[10];
struct dob
{
int day;
int month;
int year;
}d;
}p;
printf("\n enter the person name and dob: ");
scanf("%s%s%d%d%d",p.fname,p.lname,&p.d.day,&p.d.month,&p.d.year);
printf("\n my name is %5s %5s",p.fname,p.lname);
printf("\n my dob is %d-%d-%d",p.d.day,p.d.month,p.d.year);
}
Post A Comment:
0 comments: