C | Structure & Union | Question 8 Read Discuss Courses Practice Improve Improve Improve Like Article Like Save Article Save Report issue Report union test { int x; char arr[4]; int y; }; int main() { union test t; t.x = 0; t.arr[1] = 'G'; printf("%s", t.arr); return 0; } Predict the output of above program. Assume that the size of an integer is 4 bytes and size of character is 1 byte. Also assume that there is no alignment needed. (A) Nothing is printed (B) G (C) Garbage character followed by ‘G’ (D) Garbage character followed by ‘G’, followed by more garbage characters (E) Compiler Error Answer: (A) Explanation: Since x and arr[4] share the same memory, when we set x = 0, all characters of arr are set as 0. O is ASCII value of ‘\0’. When we do “t.arr[1] = ‘G'”, arr[] becomes “\0G\0\0”. When we print a string using “%s”, the printf function starts from the first character and keeps printing till it finds a \0. Since the first character itself is \0, nothing is printed.Quiz of this Question Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now! Last Updated : 28 Jun, 2021 Like Article Save Article Previous C | Pointer Basics | Question 17 Next C | Structure & Union | Question 9 Please Login to comment...