RosettaCodeData/Task/Topic-variable/FreeBASIC/topic-variable.freebasic

21 lines
500 B
Plaintext

' FB 1.05.0 Win64
' Three different ways of returning a value from a function
Function Sum (x As Integer, y As Integer) As Integer
Sum = x + y '' using name of function
End Function
Function Sum2 (x As Integer, y As Integer) As Integer
Function = x + y '' using Function keyword
End Function
Function Sum3 (x As Integer, y As Integer) As Integer
Return x + y '' using Return keyword which always returns immediately
End Function
Print Sum (1, 2)
Print Sum2(2, 3)
Print Sum3(3, 4)
Sleep