Computer Science, asked by Dahalyashaswi3, 5 months ago

Q-basic
a. Write a Q-basic program to display "odd" or "even."
b. Write a Q-basic program to display the greater number between any two numbers.

Answers

Answered by harshvirsing55
2

Answer:

a.

CLS

INPUT "Enter a Number: ", n

IF n MOD 2 = 0 THEN

 PRINT "Input Number is Even"

ELSE

 PRINT "Input Number is Odd"

END IF    

END

b.

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

===================================================

Similar questions