QBasic Programming

Calculate potential energy of body. [PE=MGH where G=9.8]

REM CALCULATE POTENTIAL ENERGY OF BODY
CLS
INPUT “ ENTER MASS”; M
INPUT “ENTER HEIGHT”; H
P = M * 9.8 * H
PRINT “POTENTIAL ENERGY OF BODY”; P
END

USING SUB PROCEDURE
DECLARE SUB CALULATE(M, H)
CLS
INPUT “ ENTER MASS”; M
INPUT “ENTER HEIGHT”; H
CALL CALULATE (M, H)
END

SUB CALULATE (M, H)
P = M * 9.8 * H
PRINT “POTENTIAL ENERGY OF BODY”; P
END SUB

USING FUNCTION PROCEDURE

DECLARE FUNCTION CALCULATE (M, H)
CLS
INPUT “ ENTER MASS”; M
INPUT “ENTER HEIGHT”; H
PRINT “POTENTIAL ENERGY OF BODY”; CALCULATE (M, H)
END

FUNCTION CALCULATE (M, H)
CALULATE = M * 9.8 * H
END FUNCTION

Calculate distance.[S=UT+1/2(AT2)] (Prev Lesson)
(Next Lesson) Ask quantity of pen, copy and pencil and their rate and find out the total amount
Back to QBasic Programming

No Comments

Post a Reply

Course Curriculum

error: Content is protected !!