How to resolve the algorithm Loops/Break step by step in the Yabasic programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Loops/Break step by step in the Yabasic programming language
Table of Contents
Problem Statement
Show a loop which prints random numbers (each number newly generated each loop) from 0 to 19 (inclusive).
If a number is 10, stop the loop after printing it, and do not generate any further numbers.
Otherwise, generate and print a second random number before restarting the loop.
If the number 10 is never generated as the first number in a loop, loop forever.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Loops/Break step by step in the Yabasic programming language
Source code in the yabasic programming language
do
i = int(ran(19))
print i using "##";
print " ";
if i = 10 then break : fi
i = int(ran(19))
print i using "##", " ";
loop
print
end
You may also check:How to resolve the algorithm Substring/Top and tail step by step in the Pascal programming language
You may also check:How to resolve the algorithm Topological sort step by step in the ATS programming language
You may also check:How to resolve the algorithm Water collected between towers step by step in the Phixmonti programming language
You may also check:How to resolve the algorithm Compile-time calculation step by step in the 8086 Assembly programming language
You may also check:How to resolve the algorithm Babbage problem step by step in the ALGOL 68 programming language