Provide the definition for each of the following structures and unions: a) Struc
ID: 3654630 • Letter: P
Question
Provide the definition for each of the following structures and unions:
a) Structure inventory containing character array partName[ 30 ], integer partNumber, floating point price, integer stock and integer reorder.
b) Union data containing char c, short s, long b, float f and double d.
c) A structure called address that contains character arrays streetAddress[ 25 ], city[ 20 ], state[ 3 ] and zipCode[ 6 ].
d) Structure student that contains arrays firstName[ 15 ] and lastName[ 15 ] and variable homeAddress of type struct address from part (c).
e) Structure test containing 16 bit fields with widths of 1 bit. The names of the bit fields are the letters a to p.
Explanation / Answer
a) struct inventory { char partName[ 30 ]; int partNumber; float price; int stock ; int reorder; }; b) union data { char c, short s, long b, float f , double d}; c) struct address { char streetAddress[ 25 ], city[ 20 ], state[ 3 ] , zipCode[ 6 ] }; d)structure student { char firstName[ 15 ], lastName[ 15 ] ; struct address ; };
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.