1 Systematically analyze the lifetimes of variables of your favorite programming language. Are global, local, and/or heap variables supported? What determines the lifetime of each variable?
2 Consider the following C program:voidmain () {
intf;
f = fac(3);
}
intfactorial (intn) {
intp, i;
p = 1;
for(i = 2; i <=>
p *= i;
returnp;
(a) Make a diagram, similar to showing the lifetimes of the local variables in this program. (Note that the formal parameter n is, in effect, a local variable of the factorial function.)
(b) Repeat with the above version of the factorial function replaced by the following recursive version:intfactorial (intn) {
if(n > 1)returnn * factorial(n-1);
else return1;
=>
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here