QBASIC Program to get any two numbers from the user and print their sum on the screen.
Using SUB Procedure
DECLARE SUB sum(a,b)
INPUT "Enter First Number: "; a
INPUT "Enter Second Number: "; b
CALL sum(a,b)
END
INPUT "Enter First Number: "; a
INPUT "Enter Second Number: "; b
CALL sum(a,b)
END
SUB sum(a,b)
s=a+b
PRINT "Sum = "; s
END SUB
s=a+b
PRINT "Sum = "; s
END SUB
Using FUNCTION Procedure
DECLARE FUNCTION sum(a,b)
CLS
INPUT "Enter First Number: "; a
INPUT "Enter Second Number: "; b
s = sum(a,b)
PRINT "Sum = "; s
END
CLS
INPUT "Enter First Number: "; a
INPUT "Enter Second Number: "; b
s = sum(a,b)
PRINT "Sum = "; s
END
FUNCTION sum(a,b)
s = a+b
sum = s
END FUNCTION
s = a+b
sum = s
END FUNCTION
No comments:
Post a Comment
If you have any doubts, Please let me know.