Write a Program in C to demonstrate structure within structure.

#include<stdio.h>
#include<conio.h>
    struct add
       {
                    char hno[25];
                    char city[25];
                    long pin;
       };
       struct emp
       {
                 int Id;
                 char name[25];
                 long salary;
                 struct add add1;
       }e;
       void main()
       {
                    int i;
                    clrscr();
                    printf("Enter Employee Id : ");
                    scanf("%d",&e.Id);
                    printf("Enter Employee Name : ");
                    scanf("%s",&e.name);
                    printf("Enter Employee Salary : ");
                    scanf("%ld",&e.salary);
                    printf("Enter Employee House No : ");
                    scanf("%s",&e.add1.hno);
                    printf("Enter Employee City : ");
                    scanf("%s",&e.add1.city);
                    printf("Enter Employee Pin Code : ");
                    scanf("%ld",&e.add1.pin);
                    printf("\nDetails of Employees");
                   printf("\nEmployee Id : %d",e.Id);
                    printf("\nEmployee Name : %s",e.name);
                    printf("\nEmployee Salary : %ld",e.salary);
                    printf("\nEmployee House No : %s",e.add1.hno);
                    printf("\nEmployee City : %s",e.add1.city);
                    printf("\nEmployee Pin Code : %ld",e.add1.pin);
                    getch();
       }

No comments:

Post a Comment