Pages

Thursday, March 27, 2014

C Program to demonstrate use of nested structure

/*example of nested structure*/
#include<stdio.h>
#include<stdlib.h>
struct date
{
       int day,month,year;
};
struct student
{
       char name[25];
       struct date dob;
}s;
int main()
{
    printf("enter name of student: ");
    scanf("%s",s.name);
    printf("enter date of birth: ");
    scanf("%d%d%d",&s.dob.day,&s.dob.month,&s.dob.year);
    printf("\n date of dirth of student %s is %d/%d/%d",s.name,s.dob.day,s.dob.month,s.dob.year);
    system("pause");
    return 0;
}

No comments:

Post a Comment