Q. Write a QBasic program using user defined function pp(sp,cp) to input selling price and cost price in parameter. then calculate profit or loss percentage. use the function to return the profit pr loss percentage.
DECLARE FUNCTION PP(SP,CP)
CLS
INPUT "ENTER SELLING PRICE"; SP
INPUT "ENTER COST PRICE"; CP
PL= PP(SP, CP)
END
FUNCTION PP (SP, CP)
IF SP > CP THEN
P = ((SP - CP)) / CP * 100
PRINT "PROFIT PERCENTAGE="; P
ELSE
L = ((CP - SP)) / CP * 100
PRINT "LOSS PERCENTAGE="; L
END IF
END FUNCTION
Thank you 😊
ReplyDelete