Function returning value

In previous section we saw how we can group some common code and wrap it in a function.
We can parametrize it with different arguments when we call it.

Functions can also return a value.
Let's define a function: square(x).
It will calculate a square of a number.

Steps:

  • add a new function square node with type Integer
  • add a new parameter x with type Integer
  • click on the return node and type x * x
  • add a new Output command in the main function, and type square(5)

Run the program, it should display 25 in the output.

3 / 4