Problem 1 a Provide the definition for each of the following structures and unio
ID: 3764214 • Letter: P
Question
Problem 1 a
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).
Problem 2 Design a program to shift one high bit to the left bit by bit until it reach the position 32 and then shift to the right bit by bit until the first position as shown in the next figure:
Explanation / Answer
1.
(a)
struct inventory{
char partName[30];
int partNumber;
float price;
int stock;
int reorder;
};
(b)
union{
char c;
short s;
long b;
float f;
double d;
};
(c)
struct address{
char streetAddress[25];
char city[20];
char state[3];
char zipCode[6];
};
(d)
struct student{
char firstname[15];
char lastname[15];
address homeAddress;
};
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.