< previous page
page_826
next page >
Page 826
Exam Preparation Exercises
1. Define the following terms:
record (struct in C++)
member
member selector
hierarchical record
data abstraction
2. Given the declarations
typedef char CodeString[26]; // Max. 25 characters plus \0
enum StyleType {FORMAL, BRIEF};
struct RefType
{
CodeString token[2000];
CodeString symbol[20];
};
struct MapType
{
CodeString mapCode;
StyleType style;
RefType chart;
};
MapType guide[200];
MapType aMap;
RefType aRef;
int count;
CodeString aCode;
mark each of the following statements as valid or invalid. (Assume that all the valid variables have been assigned values.)
Statement
Valid
Invalid
a.
if (aMap.style == BRIEF)
count++
;
______
______
b.
guide[1].chart.token[2] = aMap
;
______
______
c.
guide[6].chart = aRef
;
______
______
d.
strcpy(aMap.mapCode[0], aRef.token[0])
;
______
______
e.
guide[100].chart.token[1] [2] = aCode[2]
;
______
______
f.
guide[20].token[1] = aCode
;
______
______
g.
if (guide[20].style == FORMAL)
guide[20].chart.token[0] [0] = A
;
______
______
h.
aMap = guide[5]
;
______
______
i.
aMap.chart = aRef
;
______
______
3. Using the declarations in Exercise 2, write a single statement to do each of the following:
< previous page
page_826
next page >