0
Code of c
Can anyone tell me answer of this code : union Values { int first; int second; }; int main (){ union Values v; v.first=0; v second=4+v.first; v.first=v.second+4; printf("%d\n",v.second); return 0; } Code is correct but my answer was 4 which was wrong so please tell me correct answer.
3 Answers
+ 2
Prasad Bankar answer is 8
+ 2
Prasad Bankar
at the end union variable stores 8.
Even though you declared two elements inside the union ,only one block of memory will be allocated (which has higher priority)
0
Yes but I didn't understand why v.second is 8