Computer Science, asked by anjanchakrabarti73, 2 months ago

Write a qbasic program to print the series 1,2,3,6,9,18,27,54 upto n terms

Answers

Answered by anindyaadhikari13
2

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

The given co‎de is written in QBASIC.

CLS

INPUT "Enter N - "; N

A = 1

FOR I = 1 TO N

   PRINT A;

   IF I MOD 2 = 1 THEN

       A = A * 2

   ELSE

       A = A * 3 / 2

   END IF

NEXT I

END

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

  • Here, first term is 1. Then next term is multiplied by 2 and then next term is multiplied by 3/2 and this goes on till the Nth term.

See the attachment for output.

Attachments:

MisterIncredible: Awesome ^_^
Similar questions