Rewrite the following for-loop as a pre-test while-loop. (6)
for x = 1 to 10
for y = 10 to x
if y MOD 2 = 0 then
display "*"
else
display "#"
endif
display " " ~newline
x = 1
while x <= 10
y = 10
while y >= x
if y MOD 2 = 0 then
display "*"
else
display "#"
endif
y = y - 1
display " " ~newline
x = x + 1
Comments
Leave a comment