Computer Science, asked by shreyanshpoddar318, 1 month ago

3. Write down the output of the program.
a) FOR I = 1 TO 5
FOR J= 1 TO 2
PRINT I*J;
NEXTJ
END​

Answers

Answered by anindyaadhikari13
5

\textsf{\large{\underline{Corrected C{o}de}:}}

CLS

FOR I = 1 TO 5

   FOR J = 1 TO 2

       PRINT I * J;

   NEXT J

NEXT I

END

\textsf{\large{\underline{O{u}tput}:}}

1 2 2 4 3 6 4 8 5 10

\textsf{\large{\underline{Explanation}:}}

Lets dry run the program so as to predict the output!

Inner loop iterates 2 times and displays the first two multiples of variable 'I'.

When I = 1:

> 1(1 × 1) and 2(1 × 2) - Printed.

When i = 2:

> 2(2 × 1) and 4 (2 × 2) - Printed.

When I = 3:

> 3(3 × 1) and 6(3 × 2) - Printed.

When I = 4:

> 4(4 × 1) and 8(8 × 2) - Printed.

When i = 5:

> 5(5 × 1) and 10(5 × 2) - Printed.

Hence, the final output is:

1  2  2  4  3  6  4  8  5  10

See attachment for verification.

Attachments:
Similar questions