C Quiz – 112 | Question 5
Pick the best statement for the below program:
(A) Compile error due to incorrect syntax of initialization.
(B) No compile error and it’ll print “0 100”.
(C) No compile error and it’ll print “100 100”.
Explanation: Since fields/members of union share same memory, both i1 and i2 refer to same location. Also, since both i1 and i2 are of same type, initializing one would initialize the other as well implicitly. So answer is C.
Quiz of this Question