C File =>
/* Write a program to declare a structure person (name, address) which contains another structure birthdate (day, month, year). Accept the details of n persons and display them. */
#include<stdio.h>
typedef struct Person
{
char name[30];
char addr[50];
struct birth_date
{
int day;
int month;
int year;
}b[100];
};
int main()
{
struct Person p[100];
int n,i;
printf("\n Enter how many persons : ");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("\n\n Enter name%d : ",i+1);
scanf("%s",p[i].name);
printf("\n Enter Address%d : ",i+1);
scanf("%s",p[i].addr);
printf("\n Enter birthdate(day month year)%d: ",i+1);
scanf("%d%d%d",&p[i].b[i].day,&p[i].b[i].month,&p[i].b[i].year);
}
printf("\n\n Details of Person are :");
for(i=0;i<n;i++)
{
printf("\n\n Name : %s",p[i].name);
printf("\n Address : %s",p[i].addr);
printf("\n Birth date : %d/%d/%d",p[i].b[i].day,p[i].b[i].month,p[i].b[i].year);
}
return 0;
}
Comments
Post a Comment
Please do not enter any spam link in message.