1 1 vote What is the output of the program? int main() { union a { int i; char ch[2]; }; union a u; u.ch[0] = 3; u.ch[1] = 2; printf("%d, %d, %d", u.ch[0], u.ch[1], u.i); return 0; } Programming in C programming-in-c data-types + – shiva0 1.0k views answer comment Share Follow Print 0 reply Please log in or register to add a comment.
0 0 votes 3 ,2 , garbage value hitendra singh answered Apr 4, 2019 hitendra singh comment Share Follow See all 3 Comments 3 3 Comments reply prashant281188 commented Apr 5, 2019 reply Follow flag 3, 2, garbage value 0 0 replyShare shiva0 commented Apr 6, 2019 reply Follow flag can you explain why garbage value is printed?????? 0 0 replyShare hitendra singh commented Apr 6, 2019 reply Follow flag because its not initialized 0 0 replyShare Please log in or register to add a comment.
0 0 votes answer is 3 2 515 because c processor follows little endian (in little endian mystery lower bytes are being stored at lower address and upper bytes are being stored at higher addresses) https://www.geeksforgeeks.org/little-and-big-endian-mystery/ Akanksha Agrawal answered Jun 8, 2019 Akanksha Agrawal comment Share Follow 0 reply Please log in or register to add a comment.
0 0 votes 3 2 515 Bcz char take one byte and int take 4 byte . Memory represation is lower byte store first 0000 0000 0000 0000 0000 0010 0000 0011=515 pritambiswas000007 answered Apr 19, 2020 pritambiswas000007 comment Share Follow 0 reply Please log in or register to add a comment.