Data type size & structure – Programming language
|Question 1 UGC NET June-2020 |
Suppose you are compiling on a machine with 1-byte chars, 2-byte shorts, 4-byte ints, and 8-byte doubles, and with alignment rules that require the address of every primitive data element to be integer multiple of the element’s size. Suppose further that the compiler is not permitted to reorder fields; padding is used to ensure alignment. How much space will be consumed by the following array?
}A; /10 element array of struct/
|A – 150 bytes|
|B – 320 bytes|
|C – 240 bytes|
|D – 200 bytes|