Assessment Tool

Lecture 13:  Pointer Parameters

Activity:  Drama

We have just seen the syntax and purpose for using pointer parameters.  Today we will learn more about a function you saw in today's lecture.  As a class, we will act out a mini-drama that demonstrates the execution of the following code.

/* interchange *p and *q */
void swap (int *p, int *q) {
    int temp;
    temp = *p;
    *p = *q;
    *q = temp;
}

/* somewhere in another function */
...
int a, b;
a = 4;
b = 7;
swap(&a, &b);