Data type size & structure – Programming language

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?
struct {
short s;
char c;
short t;
char d;
double r;
int i;
}A[10]; /10 element array of struct/
A – 150 bytes
B – 320 bytes
C – 240 bytes
D – 200 bytes

Show Answer With Best Explanation

Answer : C


error: Content is protected !!
Open chat
1
Hi,how Can We Help You ?