Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

My homework requires that that I identify variables and predict the output of th

ID: 3628114 • Letter: M

Question

My homework requires that that I identify variables and predict the output of this void function using the following numbers as input 5, 4, 6, 7

I know the variables are x, y, a, b, and that the initial value of x = 5, and y = 4. I believe the initial value of a = 5 and b = 4. I just can't figure out what to do next.

Please help me.

void t( int );
main()
{ int x,y,a,b;
cin >>x>>y;
a = t ( x );
cout << a<<x<<endl;
b = t ( y );
cout <<b<<y;
}
int t ( int d )
{ int w;
w = d * 2 + 3;
return(w);
}

Explanation / Answer

cin >>x>>y
The input statement accepts values for x and y

x = 5
y = 4

a = t(x);
This calls the t function. t function accepts d = x = 5.
w = d*2 + 3 = 13.
Then it returns w = 13 to a.
So, a = 13.

Now the variables a and x are displayed as output.

So, a = 13 and x = 5 is the first output.

Then, again the t function is called.
d = y = 4.
w = 2*4 + 3 = 11.
So, b = 11.

The next output is d = 11, y = 4.

That's it!

So, the net output is this:
13 5
11 4
For the input:
5,4

For the input:

6,7

Output will be:

15 6

17 7

So, final output will be:

13 5

11 4 15 6

17 7

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at drjack9650@gmail.com
Chat Now And Get Quote