WAP to store a number. Now display cube of the number if its positive otherwise display its square Qbaisc
Answers
Answered by
3
The given code 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
- 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
3
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
Psychology,
1 month ago
Biology,
1 month ago
Science,
1 month ago
English,
2 months ago
Environmental Sciences,
9 months ago
English,
9 months ago