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

Determine what values are stored in each variable after executing the following

ID: 638957 • Letter: D

Question

Determine what values are stored in each variable after executing the following pseudocode instructions. You must show your work.

7.

q = 14

r = 15

if (q > 12)

{

q = q + r + 1

}

8.

u = 3

if (u <= 3)

{

u = u + 5

u = u + u

}

u = 5

9.

w = 1

while (w < 5)

{

w = w + 3

}

10.

v = 10

while (v >= 2)

{

If ( v > 6)

{

v = v - 1

}

v = v

7.

q = 14

r = 15

if (q > 12)

{

q = q + r + 1

}

8.

u = 3

if (u <= 3)

{

u = u + 5

u = u + u

}

u = 5

9.

w = 1

while (w < 5)

{

w = w + 3

}

10.

v = 10

while (v >= 2)

{

If ( v > 6)

{

v = v - 1

}

v = v

Explanation / Answer

7.

q = 14

r = 15

if (q > 12) --> true (14 > 12)

{

q = q + r + 1 --> q = 14 + 15 + 1 = 30

}

result : q = 30


8.

u = 3

if (u <= 3) --> true (3 <= 3)

{

u = u + 5 --> u = 3 + 5 = 8

u = u + u --> u = 8 + 8 = 16

}

u = 5 --> u = 5

result : u = 5


9.

w = 1

while (w < 5) --> true for w = 1 and w = 4(until 'w' becomes 5)

{

w = w + 3 --> while 1 < 5, w = 1 + 3 = 4 and while 4 < 5, w = 4 + 3 = 7

}

result : w = 7


10.

v = 10

while (v >= 2) --> true for v = 10 and v = 7 and v = 4 and v = 2

{

If ( v > 6) --> true for v = 10 > 6 and v = 7 > 6, false for v = 4, v = 2

{

v = v - 1 --> v = 10 - 1 = 9, v = 7 - 1 = 6

}

v = v

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