Starting from:

$29

Assignment 12 Solution


Assignment 12
Total: 25 Points
General Instruction
• Allowed submission file type for the questions: PDF only
• I recommend that you type your answers to exercise questions by using a word processor
(Microsoft word, LibreOffice writer, LATEX, etc.).
• If you would write your answers to questions on papers, then you can scan them by
using a scanner (Not phone/tablet/laptop camera) and convert to a single PDF file
(Not separate image files). Please use a pen and make it legible.
• Submit your work via BeachBoard (Not email or in class).
1. (5 points) Elaborate on the reasons why even though parameters passed in registers may
sometimes need to have locations in the stack.
2. (10 points) Consider the following function and call:
procedure f(x, y, z)
x := x + 1
y := z
z := z + 1
. . .
i := 1; a[1] := 10; a[2] := 11
f(i, a[i], i)
print(i, a[1], a[2])
Determine the outputs of the program if arguments are passed 1) by value, 2) by reference, and 3) by name.
3. (10 points) Check out the output of the following program in C in your system and
suggest an explanation in terms of activation records in the stack.
void foo() {
int i;
printf("%d ", i++);
}
int main() {
int j;
for (j = 1; j <= 10; j++) {
foo();
}
}

More products