QBasic Programming

Display sum of square of any three input numbers

REM PROGRAM TO DISPLAY SUM OF SQUARE OF ANY THREE INPUT NUMBERS
CLS
INPUT “ENTER FIRST NUMBER”; A
INPUT “ENTER SECOND NUMBER”; B
INPUT “ENTER THIRD NUMBER”; C
S = A ^ 2 + B ^ 2 + C ^ 2
PRINT “SUM OF SQUARE OF THREE NUMBERS ”; S
END

USING SUB PROCEDURE

DECLARE SUB SQUARE (A, B, C)
CLS
INPUT “ENTER FIRST NUMBER”; A
INPUT “ENTER SECOND NUMBER”; B
INPUT “ENTER THIRD NUMBER”; C
CALL SQUARE(A, B, C)
END
SUB SQUARE (A, B, C)
S = A ^ 2 + B ^ 2 + C ^ 2
PRINT “SUM OF SQUARE OF THREE NUMBERS “; S
END SUB

USING FUNCTION PROCEDURE

DECLARE FUNCTION SQUARE (A, B, C)
CLS
INPUT “ENTER FIRST NUMBER”; A
INPUT “ENTER SECOND NUMBER”; B
INPUT “ENTER THIRD NUMBER”; C
S = SQUARE(A, B, C)
PRINT “SUM OF SQUARE OF THREE NUMBERS “; S
END
FUNCTION SQUARE (N)
SQ= A ^ 2 + B ^ 2 + C ^ 2
SQUARE = SQ
END FUNCTION

Display sum of cube of any two input numbers (Prev Lesson)
(Next Lesson) Display sum of cube of any three input numbers
Back to QBasic Programming

No Comments

Post a Reply

Course Curriculum

error: Content is protected !!