How to resolve the algorithm Loops/Nested step by step in the Run BASIC programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Loops/Nested step by step in the Run BASIC programming language

Table of Contents

Problem Statement

Show a nested loop which searches a two-dimensional array filled with random numbers uniformly distributed over

[ 1 , … , 20 ]

{\displaystyle [1,\ldots ,20]}

. The loops iterate rows and columns of the array printing the elements until the value

20

{\displaystyle 20}

is met. Specifically, this task also shows how to break out of nested loops.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Loops/Nested step by step in the Run BASIC programming language

Source code in the run programming language

dim a(10,10)
cls
for row = 1 TO 10
        for col = 1 TO 10
                a(row,col) = INT(20 * RND(1) + 1)
        next col
next row
 
for row = 1 to 10
        for col = 1 to 10
               print a(row, col)
                if a(row, col) = 20 then goto [end]
        next col
next row
[end]
print "At row:";row;" col:";col

  

You may also check:How to resolve the algorithm Loops/For step by step in the Klong programming language
You may also check:How to resolve the algorithm Integer overflow step by step in the Computer/zero Assembly programming language
You may also check:How to resolve the algorithm Greatest element of a list step by step in the Ela programming language
You may also check:How to resolve the algorithm Unix/ls step by step in the Elixir programming language
You may also check:How to resolve the algorithm Modular exponentiation step by step in the AutoHotkey programming language