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; }
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/
64.3k questions
77.9k answers
244k comments
80.0k users