Computer Science, asked by spratyush, 1 month ago

WAP to display 1st 5 even natural numbers in reverse order using FOR & WHILE Loop.

Answers

Answered by anindyaadhikari13
2

\texttt{\textsf{\large{\underline{Approach!}}}}

The given problem is solved using - QBASIC.

1. Using For Loop:

CLS

A = 2

FOR I = 5 TO 1 STEP -1

   PRINT 2 * I;

NEXT I

END

2. Using While Loop:

CLS

A = 2

I = 5

WHILE I > 0

   PRINT 2 * I;

   I = I - 1

WEND

END

\texttt{\textsf{\large{\underline{Logic!}}}}

  • Iterate loop For X = 5 to 1.
  • Display the value of 2X.

See attachment for output.

Attachments:
Similar questions