Skip to content
Related Articles
Open in App
Not now

Related Articles

ISRO | ISRO CS 2020 | Question 12

Improve Article
Save Article
  • Last Updated : 03 Sep, 2020
Improve Article
Save Article

Following declaration of an array of struct, assumes size of byte, short, int and long are 1, 2, 3 and 4 respectively. Alignment rule stipulates that n-byte field must be located at an address divisible by n. The fields in a struct are not rearranged, padding is used to ensure alignment. All elements of array should be of same size.

Struct complx
  Short s
  Byte b
  Long l
  Int i
End complx
Complx C[10] 

Assuming C is located at an address divisible by 8, what is the total size of C, in Bytes ?
(A) 150
(B) 160
(C) 200
(D) 240

Answer: (B)

Explanation: Size of complex data type will be,

= 2 + 1 + 4 + 3 
= 10 Bytes 

But, address divisible by 8, so, it should be minimum,

= 10+6 
= 16 Bytes 

Therefore, total size of such 10 data types,

= 16*10
= 160 Bytes 

So, option (B) is correct.

Quiz of this Question

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!