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...


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:
void
main () {



int
f;


f = fac(3);


}



int
factorial (int
n) {



int
p, i;


p = 1;



for
(i = 2; i <=>


p *= i;



return
p;


}


(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:
int
factorial (int
n) {



if
(n > 1)
return
n * factorial(n-1);



else return
1;


}



Nov 16, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here