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);
}
Mukesh Rajput

Mukesh Rajput

I am a Computer Engineer, a small amount of the programming tips as it’s my hobby, I love to travel and meet people so little about travel, a fashion lover and love to eat food, I am investing a good time to keep the body fit so little about fitness also..

Post A Comment:

0 comments: