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

Consider this structure declaration: Struct Wardrobe 3. double collarsize; int w

ID: 3709738 • Letter: C

Question

Consider this structure declaration: Struct Wardrobe 3. double collarsize; int waistsize; int inseamsize; Wardrobe YourClothing; a. If doubles are four bytes and integers are two bytes, what is the amount of b. How will you refer to waistsize? c. Assume the following declaration: Wardrobe family[8]; how will you d. Given this added structure declaration: memory set aside by this declaration? refer to the first family member's collarsize? Struct Shoplist int spendlimit; string favoritestore; Wardrobe sizes; Shoplist Jerry; How will you refer to Jerry's collarsize? e. What is wrong with each of the following statements? a. Shoplist[1].spendlimit 1000; b. family.waistsize[51 32;

Explanation / Answer

3.(a) If doubles are four bytes and integers are 2 bytes , then the memory set aside by the declaration Wardrobe YourClothing is 4+2+2 =8 bytes. Since YourClothing is struct type which contains a double attribute , and two integers attributes.

(b)

We can refer to waistsize from Wardrobe YourClothing, by using the dot operator, YourClothing.waistsize -> refers to waistsize attribute of YourClothing

(c)

To refer to first family member's collarsize in Wardrobe family[8] , we use family[0].collarsize since the index of array starts from 0. So family[0] will be the first family member and to refer to its collarsize ,we use the dot operator i.e

family[0].collarsize

(d)

Jerry is a variable of type struct Shoplist, which contains the attribute sizes of Wardrobe type. To refer to Jerry's collarsize, we first refer to the sizes attribute of Jerry and then refer to the collarsize attribute of sizes in order to refer to collarsize of Jerry i.e Jerry.sizes.collarsize

(e)(a) Shoplist is a struct type and not a variable , and hence we cannot assign Shoplist[1].spendlimit = 1000. We first declare an array of Shoplist type, say list[3] and then use list[1].spendlimit = 1000;

(b) family is an array of Wardrobe type and waistsize is an attribute of Wardrobe of type int which is not an array.

Correct statement is : family[5].waistsize = 32;