Answered step by step
Verified Expert Solution
Question
1 Approved Answer
4. (9.5) Modify the program in Figure 9.1 so that the function B has no side effects on the global variable i. Instead, B should
4. (9.5) Modify the program in Figure 9.1 so that the function B has no side effects on the global variable i. Instead, B should return an int value, which is the calculation 2*w. Also, the call to B from A should be modified so that this result is assigned to the global variable i. The local variable declaration of i within A should be removed. Run this modified program using your favorite C++ compiler and answer the following questions: (a)Describe the activation record that occurs when this call is interpreted (b) This modified program has the same global effect as the original program in Figure 9.1. What would have happened if you had not removed the declaration of the local variable i from A? program from Figure 9.1 int h, i; void B(int w) ( int j, k; w w+1 ; = void A(int x, int y) ( int i, j; B(h); int main() int a,b; h=5; a=3, A(a,b); b=2
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