Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!