Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For the C++ program show on the next page, answer the questions that follow.The names g, j, x, and y are declared multiple times. Distinguish

For the C++ program show on the next page, answer the questions that follow.The names g, j, x, and y are declared multiple times. Distinguish uses of these names using line numbers where they were declared as subscripts.

a.At point A in the program, what names are in scope?

b.At point A in the program, what variables are live?

c.At point B in the program, what names are in scope?

d.At point B in the program, what variables are live?

Code for Problem III.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

int g;

int h;

int bar(int x, int y) {

int f = x + y;

int g = 2 * h;

while (f < 0) {

int x = f - 1;

int y = g - 1;

g = x + y;

f--;

}

// Point A

f++;

int z = f * g;

return z;

}

int j = g + h;

void print(int v);

int foo(int a) {

int x = a * 2;

// Point B

int r = bar(a, x);

return r;

}

int main() {

int j = 3;

int k = 4;

int m = foo(j + k);

print(m);

return 0;

}

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

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions