STRUCTURE IN STRUCTURE EXAMPLE PROGRAM IN C

 #include<stdio.h>  
 struct date  
 {  
      int year;   
      int month;  
      int day;  
 };  
 struct student   
 {  
      char name[20];  
      struct date dob;   
 };  
 main()  
 {  
      struct student s1;   
      printf("Enter student Name\n");  
      scanf("%s",s1.name);  
      printf("Enter Date of Birth\n");  
      scanf("%d%d%d",&(s1.dob.year),&(s1.dob.month),&(s1.dob.day));  
      printf("%s\n%d-%d-%d\n",s1.name,s1.dob.day,s1.dob.month,s1.dob.year);       
 }  

Post a Comment

0 Comments