<!DOCTYPE
HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"><!--Converted with
LaTeX2HTML 96.1-beta (Jan 15, 1996) by Nikos Drakos (nikos@cbl.leeds.ac.uk),
CBLU, University of Leeds -->CS471 Programming Language Structure I
Fall 2001
Consider the following program written in C syntax:
int main() {
int value = 2, list[5] = {1, 3, 5, 7, 9};
swap(value, list[0]);
swap(list[0], list[1]);
swap(value, list[value]);
}
void swap(int a, int b) {
int temp;
temp = a;
a = b;
b = temp;
}
For each of the following parameter passing methods, what are the values of the variable value and all the elements of list after each of the threee calls to swap? (You should list six values for each of the three calls for each method, making 72 in all). Use the definitions of the parameter passing methods as given in chapter 8 of the text book (chapter 9 in the new edition).
1. pass by value
2. pass by reference
3. pass by name
4. pass by value-result
This assignment is worth 50 points. Each part will be graded equally.
This assignment must be submitted through WebCT, so it must be prepared electronically. Read the drop box information page before submitting it. Pay close attention to the availability “window” of the assignment. When the window closes, you will not be able to submit an answer.