Computer Science, asked by spratyush, 2 months ago

WAP to display even numbers from 1 to 19 using FOR & While Loop qbasic

Answers

Answered by anindyaadhikari13
3

\texttt{\textsf{\large{\underline{Solution}:}}}

The given problem is solved using QBASIC.

1. Using For Loop:

CLS

FOR I = 1 TO 19

   IF I MOD 2 = 0 THEN

       PRINT I;

   END IF

NEXT I

END

2. Using While Loop:

CLS

I = 1

WHILE I < 20

   IF I MOD 2 = 0 THEN

       PRINT I;

   END IF

   I = I + 1

WEND

END

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

  • Loop FOR X = 1 to 19
  • Check if X is divisible by 2 or not. If true, display the number.

See attachment for output.

Attachments:
Similar questions