# QBasic Programming

## Input selling price and cost price calculate profit or loss percentage

CLS
INPUT “ENTER COST PRICE&SELLING PRICE”; CP, SP
IF CP > SP THEN
LP = ((CP - SP)/CP) * 100
PRINT "LOSS PERCENTAGE="; LP
ELSEIF SP > CP THEN
PP = ((SP - CP)/CP) * 100
PRINT "PROFIT PERCENTAGE"; PP
ELSE
PRINT "NEITHER PROFIT NOR LOSS"
END IF : END
USING SUB PROCEDURE
DECLARE SUB PP(SP, CP)
CLS
INPUT “ENTER COST PRICE&SELLING PRICE”; CP, SP
CALL PP(SP, CP)
END
SUB PP (SP, CP)
IF CP > SP THEN
LP = ((CP - SP)/CP) * 100
PRINT "LOSS PERCENTAGE="; LP
ELSEIF SP > CP THEN
PP = ((SP - CP)/CP) * 100
PRINT "PROFIT PERCENTAGE"; PP
ELSE
PRINT "NEITHER PROFIT NOR LOSS"
END IF : END SUB
USING FUNCTION PROCEDURE
DECLARE FUNCTION PP(SP, CP)
CLS
INPUT “ENTER COST PRICE”; CP
INPUT “ENTER SELLING PRICE”; SP
C = PP(SP, CP) : END
FUNCTION PP (SP, CP)
IF CP > SP THEN
LP = ((CP - SP)/CP) * 100
PRINT "LOSS PERCENTAGE="; LP
ELSEIF SP > CP THEN
PP = ((SP - CP)/CP) * 100
PRINT "PROFIT PERCENTAGE"; PP
ELSE
PRINT "NEITHER PROFIT NOR LOSS"
END IF : END FUNCTION