Top

Discussion

What is the output of this program?

#include 
int main()
{
    union demo {
        int x;
        int y;
    };
 
    union demo a = 100;
    printf("%d %d",a.x,a.y);
}

 

  • A.100 0
  • B.100 100
  • C.0 0
  • D.Compilation Error

Answer: D

You cannot initialize an union variable like this.

No comment is present. Be the first to comment.
Loading…

Post your comment