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 input cost price and selling price and check whether there is profit or loss

 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

Post Top Ad

Your Ad Spot

Pages