Questions 1-3 concern the following set of#defines and struct definitions: #de f
ID: 3751799 • Letter: Q
Question
Questions 1-3 concern the following set of#defines and struct definitions: #de fine #de fine NAMES|ZE TEAMS IZE 20 100 typedef struct char first[SIZE] char last[SIZE] int PID; double gpa; ) studentT; typedef struct studentT captain; studentT members [TEAMSI ZE] teamT 1) (8 pts) With justification, determine the number of bytes allocated in the malloc stateme shown below. Assume that a char is stored in 1 byte an int is stored in 4 bytes and a double stored in 8 bytes. teamT * IMTeams malloc (sizeof (team T) * 50) ; =Explanation / Answer
Question 1:
typedef struct {
char first[20];--------------- 20
char second[20];----------------20
int PID;------------------------------4
double GPA;-----------------------8
}studentT;--------------------52 bytes
typedef struct {
studentT captain;---------------52 bytes
studentT members[100];----------------5200 bytes
}teamT;-------------5252 bytes
padding may increase the size due to padding in structures . So compiler may return size greater than 52bytes and 5252 bytes for studentT and teamT.
2.
sizeof IMTeams = 50 * 5252 = 262600 bytes
Do ask if any doubt. Please upvote.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.