Monday, June 18, 2012

To demonstrate working of Union


/* Program to demonstrate working of Union */

#include<stdio.h>

#include<conio.h>

#include<string.h>

/* Union Definition */

  union Data

  {

    int i;

    float f;

    char c[20];

  };

 

void main()

{

  union Data d;

  clrscr();

  printf("\nMemory occupied by Union:%d",sizeof(d));

  getch();

}

 

OUTPUT

Memory occupied by Union:20

 

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.