Open In App

GATE | GATE-CS-2000 | Question 17

Consider the following C declaration




struct {
    short s [5]
    union {
         float y;
         long z;
    }u;
} t;

Assume that objects of the type short, float and long occupy 2 bytes, 4 bytes and 8 bytes, respectively. The memory requirement for variable t, ignoring alignment considerations, is

(A) 22 bytes
(B) 14 bytes
(C) 18 bytes
(D) 10 bytes

Answer: (C)
Explanation: See question 3 of https://www.geeksforgeeks.org/c-language-set-1/amp/
Quiz of this Question

Article Tags :