Question
Using the C++ program below answer the questions that follow. 1 int a = 0; //global variables 2 int b = 0; 3 int getVal(int
Using the C++ program below 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?
The stack should look like this: https://imgur.com/a/Yt12zhJ
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started