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

Uniqname (required) Unigname (required) Question 3: Code Reading (20 points) You

ID: 3714021 • Letter: U

Question

Uniqname (required) Unigname (required) Question 3: Code Reading (20 points) You may assume that all necessary # includes and using namespace std; are included at the beginning of each program. All the programs will compile. If you can not fit all output on a single line, it is OK to wrap it onto the next line. We recommend using scratch paper to draw out pictures or perform any necessary calculations. 3a (5 points) 3b (5 points) int &j;, int int main () ( void funnySwap (int &i;, bool xtrue; bool y -true; bool z false; while (x) i=i-j; if (y) f if (z) f y = false; void boop (int &x;, int &y;, int &z;) f cout

Explanation / Answer

the first code(3a)...will print the following output:::

output ::: Hail! Blue! Hail! Engr 101! Hail! Victors! Hail!

For iteration 1:

x = true; y = true; z = false;

This prints "Hail!"

For iteration 2:

x = true; y = true; z = true;

This prints "Blue! Hail!"

For iteration 3:

x = true; y = false; z = false;

This prints "Engr 101! Hail!"

For iteration 4:

x = true; y = false; z = false;

This prints "Victors! Hail!"

Here in iteration 4 x is set to false;Hence the loop ends;

Second question:::(3b)::

OUTPUT ::

a = 13

b = 12

c = 29

d = 15

at starting, a = 12;b = 13;c = 14;d = 15;

funnyswap(b,a,c) will swap a and b values;

hence now, a = 13;b = 12;c = 14;d = 15;

boop(c,d,b) will change the valyes as follows;

c = c+d; (Note:: in boop funcion the line z=y is not values assigning.its just copying the address.hence no change in z value)

hence c= 14+15=29

hence finally a = 13;b = 12;c = 29;d = 15;