Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

What is the size of the following data structures in bytes. a) Size of polar 3D_

ID: 3787986 • Letter: W

Question

What is the size of the following data structures in bytes. a) Size of polar 3D____ struct polar 3D {signed long radius; float Phi; double Theta;}; b) Size of allDataTypes____ union allDataTypes {char cit?Code[8]; int ival[8]; float fval[3]; double dval[4];}; c) Size of complexNuin____ struct complexNum {double *real; double * imaginary long long modulus; union {short *phi; int *angle;} degree;}; d) Size of compound____ struct compound {char name[20]; short int age; unsigned int pay; long *height; union {short * myaddress; unsignied int bytefields; char hexval[8];} short_pointer; union {char *text_data; int *numeric_data; ling l_nueric_data;} data;};

Explanation / Answer

a) Size of polar3D is 16 bytes

As the signed long size is 4 bytes, then float datatype has 4 bytes, and the double datatype is 8 bytes.

As the size of the structure depends on its members datatypes so by adding all its members in polar3D total size is 16bytes.

b) size of allDatatypes is 84 bytes

Here the char datatype size is 1 byte only here in the character array it is holding 8 characters so final size is 8 bytes.

Then int datatype size depends on your computer it might be 2 bytes or 4 bytes here i took it as 4 bytes so it is holding 8 integers, 8*4 =32 bytes.

Then float size is 4 bytes here it is holding 3, so 3*4= 12 bytes.

then double value is 8 bytes, here it is having 4, so 4*8=32 bytes and then by all adding we get 84 bytes as the final answer.

c) Size of complexNum is 26 Bytes

Here in this contains pointers actually pointers have 4 bytes in general because it contains only the value of memory location. That too this value is not fixed in c and c++ because it depends on the computer and os you are using. In certain conditions pointers have the same size as datatypes which is specified,

here in this we have 2 double datatyped pointers so , 2*8 =16 bytes

then Long have 4 bytes then Short have 2 bytes and then int have 4 bytes.

So finally by adding all we get 26 bytes

d) size of compund is 52 bytes

Like calculated above here char= 20,short int =1,unsigned int =4, long= 4, short=1,unsigned int 4,char=8, char=1, int=4, long =4 bytes.

All become 52 bytes.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote