QBASIC program to calculate and display the simple interest
CLS
INPUT "Enter Principal amount:"; p
INPUT "Enter time:"; t
INPUT "Enter rate of interest:"; r
si = p * t * r / 100
PRINT "Simple interest="; si
END
By using SUB procedure (SUB..END SUB)
DECLARE SUB si (p, t, r)
CLS
INPUT "Enter Principal amount:"; p
INPUT "Enter time:"; t
INPUT "Enter rate of interest:"; r
CALL si(p, t, r)
END
SUB si (p, t, r)
i = p * t * r / 100
PRINT "Simple interest="; i
END SUB
By using FUNCTION procedure (FUNCTION…END FUNCTION)
DECLARE FUNCTION si (p, t, r)
CLS
INPUT "Enter Principal amount:"; p
INPUT "Enter time:"; t
INPUT "Enter rate of interest:"; r
i = si(p, t, r)
PRINT "Simple interest="; i
END
FUNCTION si (p, t, r)
si = p * t * r / 100
END FUNCTION
Output:
No comments:
Post a Comment