This assignment tests your understanding of scope and lifetime of variables. There are three questions, the first two of which are given in Pascal syntax, and the last involves the various kinds of variables in C.
program P;
procedure A;
begin end;
procedure B;
var x: integer;
procedure C;
begin end;
procedure D;
begin end;
begin end;
begin
end.
program P;
procedure A;
begin end;
procedure B;
var x: integer;
procedure C;
begin end;
procedure D;
procedure E;
var x: integer;
begin end;
begin end;
begin end;
begin
end.
#include <stdio.h>
int y = 0;
void f() {
int x = 0;
x = x + 1;
y = x;
}
void g() {
static int x = 0;
x = x + 2;
y = x;
}
main() {
int n = 0;
while (y < 10) {
n = n + 1;
f();
g();
}
}
This assignment is worth 50 points. Questions 1 and 2 are worth 15 each, and the third is worth 20 points.
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.