//Program to declare a member of a union
//as a structure data type and to display
//the contents of the union
#include<iostream.h>
#include<conio.h>
struct date
{
int day;int month;int year;
};
union value
{
int i;
struct date bdate;
};
void main()
{
clrscr();
union value x;
x.i=16;
x.bdate.day=12;
x.bdate.month=10;
x.bdate.year=1999;
cout<<"\nInteger Value = "<<x.i<<endl;
cout<<"Structure = ";
cout<<x.bdate.day<<"/"<<x.bdate.month<<"/"<<x.bdate.year<<endl;
getch();
}
No comments:
Post a Comment
Note: only a member of this blog may post a comment.