Question: Study the C++ program below and then answer the questions that follow. 1 int a = 0; //global variables 2 int b = 0; 3
Study the C++ program below and then answer the questions that follow.
1 int a = 0; //global variables
2 int b = 0;
3 int getVal(int c)
4 {
5 int n = 0;
6 a = c;
7 if (n < c)
8 n = a + b;
9 return n;
10 }
11 int newVal(int c)
12 {
13 int n = 0;
14 { int a = c;
15 if (n < getVal(c))
16 n = a + b; 17 }
18 return n;
19 }
20 void main ( )
21 {
22 int j = 1; 23 int b = newVal(j);
24 cout << a + b + j << endl; 25 return 0; 26 } ------------------------------------------
a) Show the stack of activation records that would exist When line 8 has executed, but before line 9
executes.
b) Which variables are alive at this point? c) Show the stack again after the execution of line 24, but before the execution of line 25.
d) Which variables are alive now?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
