Starting from:
$30

$24

Homework Exercises Chapter 9

Exercise:

#2 In most Fortran IV implementations, all parameters were passed by reference, using access path transmission only. State both the advantages and disadvantages of this design choice.

#4 Suppose you want to write a method that prints a heading on a new output page, along with a page number that is 1 in the first activation and that increases by 1 with each subsequent activation. Can this be done without parameters and without reference to nonlocal variables in Java? Can it be done in C#?

#5 Consider the following program written in C syntax:


void swap(int a, int b) {

int temp;
temp = a;
a = b;
b = temp;
}
void main() {
int value = 2, list[5] = {1, 3, 5, 7, 9};
swap(value, list[0]);
swap(list[0], list[1]);
swap(value, list[value]);
}

For each of the following parameter-passing methods, what are all of the values of the variables value and list after each of the three calls to swap?

a. Passed by value

b. Passed by reference

c. Passed by value-result

#7 Consider the following program written in C syntax:


void fun (int first, int second) {

first += first;
second += second;
}
void main() {
int list[2] = {1, 3};
fun(list[0], list[1]);

}

For each of the following parameter-passing methods, what are the values of the list array after execution?

    a. Passed by value

    b. Passed by reference

    c. Passed by value-result




    1/1

More products