(Solved):Provide trace tables for this loop, i = 0, j = 10, n = 0 while i j, i = i + 1, j = j – 1, n = n + 1 View Answer…

 

Question

Provide trace tables for this loop,

i = 0,

j = 10,

n = 0

while i < j,

i = i + 1,

j = j – 1,

n = n + 1

 

EXPERT ANSWER

The given program starts at {eq}i = 0, j = 10, n = 0

{/eq} but after first iteration each value of the variables changes and outputs {eq}i = 1, j = 9, n = 1

{/eq}. Before the last iteration when {eq}i <j, i

Scroll to top