Settings

            

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:

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

CodeExploreLearnLog In