Spring 2000 Midterm Review

Topics


Samples of things that might be asked

Definitions

Short answer and/or true or false based on the definitions of all the stuff up there in the topics list for which I said you need to know the definition for. If you don't know the definition for some of the topics, then ask.

Understanding of types

Given the following code:

class myclass
{
public:
       int     thingy;
       double *gadget;
       char myword[20];
};

myclass var1;
char *var2;
myclass var3[10];

What are the types of the following expressions?
1. var3[2]A. int
2. thingyB. double
3. var1.mywordC. character
4. var3D. calss
5. *var2E. double pointer
6. myclassF. integer pointer
7. *(var1.gadget)G. Character pointer
8. var3.gadgetH. string
9. var1.myword+1I. myclass
10. var3[2].myword[2]J. invalid
K. none of the above

Answers:
1. I
2. J
3. G or H
4. K
5. C
6. J
7. B
8. J
9. G or H
10. C

Understanding of pointers/arrays

Show the value of each position in the array A after the following code has been performed.

    int A[5]={10,2,1,8,4};
    int *ip;
    ip=A;
    *ip=12;
    ip++;
    *ip+=4;
    *(ip+2)+= *ip;
    ip+=3;
    (*ip)++;
    *(ip-2)= *(ip-1)+2;

Answer:
[12,6,16,14,5];

Understanding of recursion

You will be asked to write a short recursive function similar to the recursive functions you did on the first assignment or the one's we covered in class.

Understangind of Classes

You will be asked to write a small class very similar to the class you had to write for Lab 3

Understanding of Strings

You will be asked to write a short function that requires you to used some of the string functions listed above.

This is the tentatibe format for the midterm. Things might change slightly here or there but if you know the above topics well you should do fine on the test. If you have any questions send email to the CS12 mailing list good luck!