Answer:
a)
struct inventory // structure inventory
{
char partName[ 30 ]; // char array
int partNumber; // variable partNumber
float price; // FLOAT VARIABLE PRICE
int stock ; // INT VARIABLE STOCK
int reorder; // INTEGER VARIABLE RECORDER
};
b)
union data // structure union
{
char c; // char variable
short s; // short variable
long b; //
long variable float f ; // float variable
double d ; // double variable
};
c)
struct address // structure address
{
char streetAddress[ 25 ]; // character array
char city[ 20 ]; // variable char
char state[ 3 ] ; // state array
char zipCode[ 6 ]
; // zipcode array
};
d)
structure student // structure student
{
char firstName[ 15 ]; // array first name
char lastName[ 15 ] ; // array last name
struct address * ; // holding the home address
};
e)
struct test
{
unsigned a:1, b:1, c:1, d:1, e:1, f:1, g:1, h:1, i:1, j:1, k:1, l:1, m:1, n:1, o:1, p:1;
}; // prototype test assign value
Explanation:
Following are the description of the above part
a)
- By using the struct keyword we declared the structure .In the part (a) we declared the struct "inventory".In this structure we char array "partName " of size 30 .
- We holding the 3 int variable "partNumber" , "stock" and "reorder." and 1 float variable i.e "price ".
b)
- By using the union keyword we declared the union .In the part (b) we created the union .
- Inside that union we holding different types of datatype that are mention in the question .
C)
- By using the struct keyword we declared the structure .In the part (c) we created the structure.
- Inside that structure we holding array of character of variable "streetAddress","city","state" and "zipcode" by using char array .
d)
- By using the struct keyword we declared the structure .
- In this we declared array of "firstname" and "lastname" of char datatype .
- In the last we create a structure address by using the pointer following by struct address
e)
In the part e we created the test that contain unsigned value of thhe 16 bit and 1 width