Computer Science, asked by spratyush, 25 days ago

WAP to display 1st 5 whole numbers using FOR & WHILE Loop. in qbasic

Answers

Answered by anindyaadhikari13
2

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

The given problem is solved using - QBASIC.

1. Using For Loop:

CLS

FOR I = 0 TO 4

   PRINT I;

NEXT I

END

2. Using While Loop:

CLS

I = 0

WHILE I < 5

   PRINT I;

   I = I + 1

WEND

END

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

  • Whole number start from 0. First five whole numbers are 0, 1, 2, 3, 4.
  • Iterate loop from X = 0 to 4 -> Display the value of X.

See attachment for output.

Attachments:
Similar questions