Vidyalelo
C Programming · Q114

Structure and Union

Programming · C Programming · question 114

Q114

What will be the output of the following C code? #include union u struct unsigned char x : 2; unsigned int y : 2; p; int x; ; int main() union u u; u.p.x = 2; printf("%d ", u.p.x);

A.
Compile time error
B.
2
Answer
C.
Undefined behaviour
D.
Depends on the standard

Answer: Option B

Solution

Answer: Option B
No explanation is given for this question Let's Discuss on Board