Multiple choice technology programming languages

union a { int a,b; }a1; void main() { a1.a=10; a1.b=20; printf("%d",a1.a); }

  1. unknown symbol ‘a1’

  2. compile error

  3. 10

  4. 20

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

In a union, all members share the same memory location. The assignment a1.b=20 overwrites the value stored at a1.a=10. Reading a1.a after a1.b returns 20. The variable name 'a' shadows the union tag, but this doesn't affect execution.