Programming Fundamentals/Functions/BASIC: Difference between revisions
Jump to navigation
Jump to search
Content deleted Content added
Creating |
(No difference)
|
Revision as of 00:17, 19 January 2017
subroutines.bas
DECLARE FUNCTION GetF
DECLARE FUNCTION CalculateC(F)
DECLARE SUB DisplayResult(F, C)
'Main
DIM F
DIM C
F = GetF
C = CalculateC(F)
DisplayResult F, C
FUNCTION GetF()
DIM F
PRINT "Enter Fahrenheit temperature:"
INPUT F
GetF = F
END FUNCTION
FUNCTION CalculateC(F)
DIM C
C = (F - 32) * 5 / 9
CalculateC = C
END FUNCTION
SUB DisplayResult(F, C)
PRINT STR$(F) + "° Fahrenheit is " + STR$(C) + "° Celsius"
END SUB
Try It
Copy and paste the code above into one of the following free online development environments or use your own BASIC compiler / interpreter.