Write a C program to demonstrate example of Nested Structure


Introduction

I have used Code::blocks 12 compiler for debugging purpose. But you can use any C programming language compiler as per your availability.


techstudy.org

HP 15 Core i3 7th gen Laptop(4GB, 1TB HDD, Windows 10) | Rs. 31,490

Write a C program to demonstrate example of Nested Structure


  1. #include <stdio.h>
  2.  
  3. struct student{
  4. char name[30];
  5. int rollNo;
  6.  
  7. struct dateOfBirth{
  8. int dd;
  9. int mm;
  10. int yy;
  11. }DOB;
  12. };
  13.  
  14. int main()
  15. {
  16. struct student std;
  17.  
  18. printf("Enter name: ");
  19. gets(std.name);
  20. printf("Enter roll number: "); scanf("%d",&std.rollNo);
  21. printf("Enter Date of Birth [DD MM YYYY] format: ");
  22. scanf("%d%d%d",&std.DOB.dd,&std.DOB.mm,&std.DOB.yy);
  23. printf("\nName : %s \nRollNo : %d \nDate of birth : %02d - %02d - %02d\n",std.name,std.rollNo,std.DOB.dd,std.DOB.mm,std.DOB.yy);
  24.  
  25. return 0;
  26. }
  27.  

Result

C language techstudy.org

     





Related Topics




Popular Posts