Open In App
Related Articles

ISRO | ISRO CS 2015 | Question 78

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report

Consider the following C declaration 
 

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


Assume that the 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 consideration, is
 

(A)

22 bytes
 

(B)

18 bytes
 

(C)

14 bytes
 

(D)

10 bytes
 



Answer: (B)

Explanation:

Here structure creates the minimum of array and union, but union only creates the minimum for only ‘long z’ which is max.
So minimum required =18.



Quiz of this Question
Please comment below if you find anything wrong in the above post

Last Updated : 05 Apr, 2018
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads