< previous page page_826 next page >

Page 826
Exam Preparation Exercises
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
1. Define the following terms:
record (struct in C++)
member
member selector
hierarchical record
data abstraction
2. Given the declarations
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
   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;
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
mark each of the following statements as valid or invalid. (Assume that all the valid variables have been assigned values.)
Statement
Valid
Invalid
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
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;
______
______
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
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 >