205k views
4 votes
1. Write down the QBASIC code of the following: a) Write a program that asks any two numbers and display greates number.



User Saul
by
7.7k points

2 Answers

4 votes
Here is the QBASIC code for the program:

CLS
INPUT "Enter first number: ", num1
INPUT "Enter second number: ", num2
IF num1 > num2 THEN
PRINT "The greatest number is "; num1
ELSEIF num2 > num1 THEN
PRINT "The greatest number is "; num2
ELSE
PRINT "The two numbers are equal"
END IF

Step-by-step explanation:

The CLS statement clears the screen.
The INPUT statements ask the user to enter the two numbers.
The IF...THEN...ELSEIF...ELSE...END IF block checks which number is greater and displays the result accordingly. If the two numbers are equal, it displays a message stating that.
User Mrsargent
by
6.6k points
5 votes

A program to enter any two numbers and display the greater one.

REM

CLS

INPUT “ENTER ANY TWO NUMBERS”; A, B

IF A > B THEN

PRINT A; “IS GREATER”

ELSE

PRINT B; “IS GREATER”

END IF

END

USING SUB PROCEDURE:-

DECLARE SUB GREAT (A, B)

CLS

INPUT “ENTER ANY TWO NUMBERS”; A, B

CALL GREAT (A, B)

END

SUB GREAT (A, B)

IF A > B THEN

PRINT A; “IS GREATER”

ELSE

PRINT B; “IS GREATER”

END IF

END SUB

USING FUNCTION PROCEDURE:-

DECLARE FUNCTION GREAT (A, B)

INPUT “ENTER ANY TWO NUMBERS”; A, B

PRINT “THE GREATER NUMBER IS”; GREAT (A, B)

END

FUNCTION GREAT (A, B)

IF A > B THEN

GREAT = A

ELSE

GREAT = B

END IF

END FUNCTION

User Ononononon
by
8.0k points