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

Q1: Hand trace the follwing code: #include <iostream> using namespace std; void

ID: 3940034 • Letter: Q

Question

Q1: Hand trace the follwing code:

#include <iostream>

using namespace std;

void find(int& a, int b, int& c,)

int main()

{

int one, two, three;

one = 1;

two = 2;

three = 3;

find(one, two, three);

cout << one << ", " << two << ", " << three << endl;

find(two, one, three);

cout << one << ", " << two << ", " << three << endl;

find(three, two, one);

cout << one << ", " << two << ", " << three << endl;

find(two, three, one);

cout << one << ", " << two << ", " << three << endl;

return 0;

}

void find(int& a, int b, int& c)

{

int temp;

c = a * b + 2;

temp = c;

if (b==0)

    a = c / (b + 1);

a = a + c – b;

c = b * temp;

}

Explanation / Answer

#include <iostream>
using namespace std;

void find(int a, int b, int c)
int main()
{
int one, two, three;
> two = 2;
three = 3;
find(one, two, three);
cout << one << ", " << two << ", " << three << endl;
find(two, one, three);
cout << one << ", " << two << ", " << three << endl;
find(three, two, one);
cout << one << ", " << two << ", " << three << endl;
find(two, three, one);
cout << one << ", " << two << ", " << three << endl;
return 0;
}
void find(int a,int b,int c)
{
int temp;
c = a * b + 2;
temp = c;
if (b==0)
a = c / (b + 1);
a = a + c – b;
c = b * temp;
}