Question: 1 #include 2 using std::cout; 3 4 int x = 10; 5 6 int function () 7 { 8 x=x/2; 9 return x; 10 }
1 #include2 using std::cout; 3 4 int x = 10; 5 6 int function () 7 { 8 x=x/2; 9 return x; 10 } 11 12 int otherFunction ( int x ) 13 { 14 int y = function() 2; 15 x=xx; 16 return x/y; 17 } 18 19 int main() 20 { 21 x=2; 22 int x = 4; 23 cout << otherFunction ( x ) << ' ' ; 24 } The code above is correct, compilable and runnable C++ code. Using the code above, answer the following questions. 1) On line 21, which x is in scope? a. It isn't in scope at all. b. The one from line 22. c. The one from line 4. d. The one from line 15. 2) On line 8, which x is in scope? a. It isn't in scope at all. b. The one from line 22. c. The one from line 21. d. The one from line 4. 3) On line 15, which x is in scope? a. The one from line 4. b. The one from line 12. c. The one from line 21. d. The one from line 22.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
