1 votes 1 votes 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 datatype + – shiva0 asked Apr 3, 2019 shiva0 447 views answer comment Share Follow See all 0 reply Please log in or register to add a comment.
0 votes 0 votes 3 ,2 , garbage value hitendra singh answered Apr 4, 2019 hitendra singh comment Share Follow See all 3 Comments See all 3 3 Comments reply prashant281188 commented Apr 5, 2019 reply Follow Share 3, 2, garbage value 0 votes 0 votes shiva0 commented Apr 6, 2019 reply Follow Share can you explain why garbage value is printed?????? 0 votes 0 votes hitendra singh commented Apr 6, 2019 reply Follow Share because its not initialized 0 votes 0 votes Please log in or register to add a comment.
0 votes 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 See all 0 reply Please log in or register to add a comment.
0 votes 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 See all 0 reply Please log in or register to add a comment.