Programming Fundamentals/Functions/Pseudocode

From Wikiversity
Jump to navigation Jump to search

functions.txt[edit | edit source]

Function Main
    Declare Real fahrenheit
    Declare Real celsius
    Assign fahrenheit = GetFahrenheit()
    Assign celsius = CalculateCelsius(fahrenheit)
    Call DisplayResult(fahrenheit, celsius)

Function CalculateCelsius (Real fahrenheit)
    Declare Real celsius
    Assign celsius = (fahrenheit - 32) * 5 / 9
Return Real celsius

Function DisplayResult (Real fahrenheit, Real celsius)
    Output fahrenheit & "° Fahrenheit is " & celsius & "° Celsius"

Function GetFahrenheit
    Declare Real fahrenheit
    Output "Enter Fahrenheit temperature:"
    Input fahrenheit
Return Real fahrenheit

See Also[edit | edit source]