Poorly used scope rules

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 }

“Struggling with a similar assignment?” We can help!!

How it works – it’s easy

Y

Place your Order

Submit your requirements through our small easy order form. Be sure to include and attach any relevant materials.

Make a payment

The total price of your order is based on number of pages, academic level and deadline.

i

Writing process

We assign the assignment to the most qualified tutor. When the tutor completes the assignment, it is transferred to one of our professional editors to make sure that the assignment meets all of your requirements.

Once complete, we’ll send your assignment via the email provided on the order form.

 

 

Achieve academic succes with the best online tutors.