Data-Structures
December 29, 2023GATE 1995
December 29, 2023Programming
Question 34
|
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
22 bytes
|
|
14 bytes
|
|
18 bytes
|
|
10 bytes
|
Question 34 Explanation:
short [5] = 5×2 = 10
max[float, long] = max [4, 8] = 8
Total = short[5] + max[float,long] = 10 + 8 = 18
max[float, long] = max [4, 8] = 8
Total = short[5] + max[float,long] = 10 + 8 = 18
Correct Answer: C
Question 34 Explanation:
short [5] = 5×2 = 10
max[float, long] = max [4, 8] = 8
Total = short[5] + max[float,long] = 10 + 8 = 18
max[float, long] = max [4, 8] = 8
Total = short[5] + max[float,long] = 10 + 8 = 18