Computer Science, asked by afsheenbasith, 1 month ago

Write a QBASIC program to input 2 numbers and display square and cube of the smaller number.

Answers

Answered by anindyaadhikari13
1

Solution:

The given co‎de is written in QBASIC.

CLS

INPUT "Enter first number: "; A

INPUT "Enter second number: "; B

SMALLEST = A

IF B < A THEN

   SMALLEST = B

END IF

PRINT "Square of the smaller number: "; SMALLEST ^ 2

PRINT "Cube of the smaller number: "; SMALLEST ^ 3

END

Logic:

  • Input two numbers A and B.
  • Assume that the first number is the smallest, now check if second number is smaller than A or not. If true, store value of the b in 'SMALLEST' variable.
  • Now, display the square and cube of the number.

See the attachment for output.

•••♪

Attachments:
Similar questions