QBASIC program to input cost price and selling price and check whether there is profit or loss
CLS
INPUT
"Enter cost price:"; c
INPUT
"Enter selling price:"; s
IF
c > s THEN
PRINT
"There is loss of "; c - s
ELSE
PRINT
"There is profit of "; s - c
END
IF
END
By
using SUB procedure (SUB…END SUB)
DECLARE
SUB pl ()
CLS
CALL
pl
END
SUB
pl
INPUT
"Enter cost price:"; c
INPUT
"Enter selling price:"; s
IF
c > s THEN
PRINT
"There is loss of "; c - s
ELSE
PRINT
"There is profit of "; s - c
END
IF
END
SUB
By
using FUNCTION procedure (FUNCTION..END FUNCTION)
DECLARE
FUNCTION pl$ (c, s)
CLS
INPUT
"Enter cost price:"; c
INPUT
"Enter selling price"; s
PRINT
pl$(c, s)
END
FUNCTION
pl$ (c, s)
IF
c > s THEN
pl$
= "There is profit"
ELSEIF
c < s THEN
pl$
= "There is loss "
ELSE
pl$
= "There is neither profit or loss"
END
IF
END
FUNCTION
Output:
No comments:
Post a Comment