Computer Science, asked by gouravjalan827, 8 hours ago

WAP to store a number. Now display cube of the number if its positive otherwise display its square Qbaisc​

Answers

Answered by anindyaadhikari13
3

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

The given co‎de is written in QBASIC.

CLS

INPUT "Enter a number: "; A

IF A > 0 THEN

   PRINT "Cube of the number is: "; A * A * A

ELSE

   PRINT "Square of the number is: "; A * A

END IF

END

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

  • Accept the number.
  • Check if number > 0. If true, display the cube of the number.
  • If the number is less than 0, display the square of the number.

See the attachment for output.

Attachments:
Answered by purveshKolhe
3

\huge{ \green{ \boxed{ \red{ \mathfrak{answer \: : }}}}}

QBASIC::

CLS

INPUT "Enter the number: ",num

IF num > 0 THEN

PRINT num * num * num

ELSE

PRINT num * num

END IF

END

Sample I/O::

Sample input

==>3

Sample output

==>27

Logic::

==> Stores input in variable num.

==> If num is greater than 0, it prints its cube otherwise square

Hope This Helps You..

Similar questions