1.1 Rewrite the following using the specified looping structure/s:
1.1.1 Use pre-test (for-loop) and a post-test (do-loop until).
num1 = 20
do while x <= -15
display “x = “, x
x = x - 3
loop
1.1.2 Use pre-test (do-while) and a post-test (do-loop until).
for value = 5 to -15 step - 3
display “x = “, x
next value
1.1.1
for num1 = 20 to -15 step -3
display "x = ", num1
next num1
num1 = 20
do
display "x = ", num1
num1 = num1 - 3
Loop while num1 > -15
1.1.2
value = 5
do while value >= -15
display "x = ", value
value = value - 3
loop
value = 5
do
display "x = ", value
value = value - 3
loop while value > -15
Comments
Leave a comment