QBASIC Program To Find The Sum, Difference, Product and Average Of Two Numbers

 QBASIC Program To Find The Sum, Difference, Product, and Average Of Two Numbers

QBASIC Program To Find The Sum, Difference, Product and Average Of Two Numbers


QBASIC Program To Find The Sum, Difference, Product, and Average Of Two Numbers

CLS
INPUT" Enter first number"; a
INPUT" Enter second number"; b
Sum=a+b
Difference=a-b
Product=a*b
Average=(a+b)/2
PRINT" The sum is"; Sum
PRINT" The difference is"; Difference 
PRINT" The product is "; Product
PRINT" The average is"; Average
END

QBASIC Program To Find The Sum, Difference, Product and Average Of Two Numbers Using SUB Procedure

DECLARE SUB Calculate(a, b)
CLS
INPUT" Enter first number"; a
INPUT" Enter second number"; b
CALL Calculate(a, b)
END
SUB Calculate(a, b)
S=a+b
D=a-b
P=a*b
A=(a+b)/2
PRINT" The sum is"; S
PRINT" The difference is"; D 
PRINT" The product is "; P
PRINT" The average is"; A
END SUB

QBASIC Program To Find The Sum, Difference, Product and Average Of Two Numbers Using FUNCTION Procedure

DECLARE FUNCTION Sum(a, b)
DECLARE FUNCTION Diff(a, b)
DECLARE FUNCTION Prod(a, b)
DECLARE FUNCTION Avg(a, b)
CLS
INPUT" Enter first number"; a
INPUT" Enter second number"; b
PRINT" The sum is"; Sum(a, b)
PRINT" The difference is"; Diff(a, b) 
PRINT" The product is"; Product(a, b)
PRINT" The average is"; Avg(a, b)
END
FUNCTION Sum(a, b)
S=a+b
Sum=S
END FUNCTION

FUNCTION Diff(a, b)
D=a-b
Diff=D
END FUNCTION

FUNCTION Product(a, b)
P=a*b
Product=P
END FUNCTION

FUNCTION Avg(a, b)
A=(a+b)/2
Avg=A
END FUNCTION





Comments