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.
7/15/2020 1:26:19 PM
Prasad Bankar3 Answers
New AnswerPrasad 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)
Sololearn Inc.
535 Mission Street, Suite 1591Send us a message