Waiting for answer This question has not been answered yet. You can hire a professional tutor to get the answer.

QUESTION

# Scope Bruce Bolden Due: Week of October 11, 2016 CS 120 Lab 6: Scope Scope rules determine where a variable is available for use in a program and...

The following program is an example of very poorly used scope rules. The mixture of local variables, global variables, pass-by-reference, pass-by-value, and repeated variable names makes it difficult to predict what will be printed. Enter the program, without line numbers, then compile and run the program. Save the output to a file using the script command. Edit the output file, by adding text that explains for each line of the output where the variable was declared and where it's value was assigned, using the line numbers to help. For example, part of the explanation of the first line of output would be: x was declared on line 9 and it was assigned the value 0 on line 9". Print and turn in your annotated output.

1 #include 2 using namespace std;3 int function1(int x, int &y);4 int function2(int b, int &x);5 int g = 4;6 int main() {7 int a = 1;8 int b = 5;9 int x = 0;10 cout 11 cout 12 cout 13 {14 int a = 7;15 g = 10;16 cout 217 cout 18 cout 19 }20 x = function1(a,b);21 cout 22 cout 23 cout 24 x = function2(a,b);25 cout 26 cout 27 cout 28 }2930 int function1(int x, int &y) {31 int a;32 a = x-y;33 g = x+y;34 y = a+g;35 cout 36 cout 37 cout 38 return a;39 }4041 int function2(int b, int &x) {42 int temp;43 temp = b;44 b = x;45 x = temp;46 temp = function1(b,x);47 g = temp*x;48 return temp;49 }