Thursday 10 September 2020

3. Write a QBasic Program to Enter any two numbers and display its product.

3. Enter any two numbers and display its product.

 

REM PROGRAM TO DISPLAY PRODUCT OF TWO NUMBERS

CLS

INPUT “ENTER FIRST NUMBER”; A

INPUT “ENTER SECOND NUMBER”; B

P = A * B

PRINT “PRODUCT OF TWO NUMBERS”; P

END

 

USING SUB PROCEDURE

 

DECLARE SUB PROD (A, B)

CLS

INPUT “ENTER FIRST NUMBER”; A

INPUT “ENTER SECOND NUMBER”; B

CALL PROD(A, B)

END

 

SUB PROD (A, B)

P = A * B

PRINT “PRODUCT OF TWO NUMBERS”; P

END SUB

 

USING FUNCTION PROCEDURE

 

DECLARE FUNCTION PROD (A, B)

CLS

INPUT “ENTER FIRST NUMBER”; A

INPUT “ENTER SECOND NUMBER”; B

PR = PROD(A, B)

PRINT “PRODUCT OF TWO NUMBERS”; PR

END

 

FUNCTION PROD (A, B)

P = A * B

PROD = P

END FUNCTION

No comments:

Post a Comment

MCQ Question Bank Microsoft PowerPoint