Question 2: Struct and Union What is the size of the following data structures i
ID: 3886004 • Letter: Q
Question
Question 2: Struct and Union
What is the size of the following data structures in bytes.
a) Size of point3D (2 pts)
struct point3D {
signed short x;
unsigned int y;
char *z;
};
b) Size of val (2 pts)
union val {
long long llval;
char str;
short ival[2];
float fval;
double dval;
};
c) Size of compound (2 pts)
struct compound {
char mystring;
long *y;
union {
char *c;
short i;
char f;
} u;
};
d) Size of more_compound (2 pts)
struct more_compound {
char name;
int *age;
short pay;
long height;
union {
char short_id;
short normal_id;
char my_id;
} id;
union {
char *text_data;
int *numeric_data;
long *l_numeric_data;
} data;
};
Explanation / Answer
Size of point3D :12 bytes
Size of val :8 bytes
Size of compound :12 bytes
Size of more_compound :24 bytes
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.