-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathExercise 16.5
42 lines (24 loc) · 966 Bytes
/
Exercise 16.5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
1. (Practice) Assume the following definition has been made:
union
{
double rate;
double taxes;
int num;
} flag;
For this union, write cout statements to display the members of the union.
2. (Practice) Define a union variable named car containing an integer named year, an array of
10 characters named name, and an array of 10 characters named model.
3. (Practice) Define a union variable named factors that allows referencing a double-precision
number by the variable names watts and power.
4. (Practice) Define a union data type named Amt containing an integer variable named intAmt,
a double-precision variable named dblAmt, and a pointer to a character variable named ptKey.
5. (Desk check) a. What do you think the following section of code will display?
union
{
char ch;
double btype;
} alt;
alt.ch = 'y';
cout << alt.btype;
b. Include the code in Exercise 5a in a program, and run the program to verify your answer to
Exercise 5a.