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? a. struct point { char x; int

ID: 3638780 • Letter: W

Question

What is the size of the following data structures?

a. struct point {
char x;
int y;
long z;
}
size:bytes
b. union fval {
unsigned char ch;
unsigned ival;
float fval;
double dfal;
int array[12];
}
size:bytes
c. struct tcp_flag {
unsigned short res1:4;
unsigned short doff:4;
unsigned short fin:1;
unsigned short syn:1;
unsigned short rst:1;
unsigned short psh:1;
unsigned short ack:1;
unsigned short urg:1;
unsigned short res2:2;
}
size:bytes
d. struct symbol {

char *name;

int flags;

int utype;

union {

long lval;

float fval;

char *sval;

}

}
size:bytes

Explanation / Answer

Dear, a)      For given structure:     struct point {
      char x;
      int y;
      long z;
   } Size:9 Bytes b) For union memory allocation is done for maximum size data value        
union fval {
unsigned char ch;
unsigned ival;
float fval;
double dfal;
int array[12];
} Size: 48 Bytes c) struct tcp_flag {
unsigned short res1:4;
unsigned short doff:4;
unsigned short fin:1;
unsigned short syn:1;
unsigned short rst:1;
unsigned short psh:1;
unsigned short ack:1;
unsigned short urg:1;
unsigned short res2:2;
}
Size: 9 Bytes d) For union nested in structure Symbol Structure 9 bytes+ union 4 bytes For union nested in structure Symbol Structure 9 bytes+ union 4 bytes Size: 13 Bytes
Hope this will help you..
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