Computer for SEE and NEB

It is a complete SEE and NEB solution for computer science. It includes Computer Fundamentals, Database (SQL), Programming in C QBASIC, CSS, JavaScript, and PHP for beginners.

Breaking

Post Top Ad

Your Ad Spot

Wednesday, November 30, 2022

QBASIC program to calculate profit and loss percentage

 QBASIC program to calculate profit and loss percentage


CLS

INPUT "Enter cost price"; c

INPUT "Enter selling price:"; s

IF c > s THEN

l = ((c - s) / c) * 100

PRINT "Loss percentage:"; l

ELSEIF s > c THEN

p = ((s - c) / c) * 100

PRINT "Profit percentage:"; p

ELSE

PRINT "There is neither profit nor loss"

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

l = ((c - s) / c) * 100

PRINT "Loss percentage:"; l

ELSEIF s > c THEN

p = ((s - c) / c) * 100

PRINT "Profit percentage:"; p

ELSE

PRINT "There is neither profit nor loss"

END IF

END SUB

 

 

By using FUNCTION procedure (FUNCTION….END FUNCTION)

DECLARE FUNCTION pl ()

CLS

x = pl

END

 

FUNCTION pl

INPUT "Enter cost price"; c

INPUT "Enter selling price:"; s

IF c > s THEN

l = ((c - s) / c) * 100

PRINT "Loss percentage:"; l

ELSEIF s > c THEN

p = ((s - c) / c) * 100

PRINT "Profit percentage:"; p

ELSE

PRINT "There is neither profit nor loss"

END IF

END FUNCTION


Output:



No comments:

Post a Comment

Post Top Ad

Your Ad Spot

Pages