Tuesday, May 29, 2018

Structure and unions in c

structures and unions(click on this link)


Nested of structure program:-

#include <stdio.h>
#include<conio.h>
struct Employee
{
   char ename[20];
   int ssn;
   float salary;
   struct date
       {
       int date;
       int month;
       int year; 
       }doj;
}emp = {"Pritesh",1000,1000.50,{22,6,1990}};

void main()
{
printf("\nEmployee Name   : %s",emp.ename);  
printf("\nEmployee SSN    : %d",emp.ssn);  
printf("\nEmployee Salary : %f",emp.salary);  
printf("\nEmployee DOJ    : %d/%d/%d", \
         emp.doj.date,emp.doj.month,emp.doj.year);  
getch();
}

No comments:

Post a Comment