Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Datacasting How To Stream Databases Over The Internet

Authors: Jessica Keyes

1st Edition

007034678X, 978-0070346789

More Books

Students also viewed these Databases questions

Question

What is linear transformation? Define with example

Answered: 1 week ago

Question

What are the Five Phases of SDLC? Explain each briefly.

Answered: 1 week ago

Question

How can Change Control Procedures manage Project Creep?

Answered: 1 week ago