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:
square
node with type Integerx
with type Integerreturn
node and type x * x
Output
command in the main function, and type square(5)
Run the program, it should display 25
in the output.