Last time we examined the variable types available to us and discussed how there were many possibilities for things we could do with arrays.
This time we’ll be putting some of these ideas and concepts into action by writing functions and demonstrating recursion.
Declaring a function in C is done like so:

It is very similar to Java that we’ve seen before. You have your modifier, your return type and your function name, with any arguments being included in the brackets.
With the function declared and with it taking some arguments, we’ll have to write the body. We’ll write a function that takes three numbers and multiplies them together.

Now when we call that function, we’ll pass it three values. Those values will then get multiplied together and the result will be returned.
We’re now ready to write something recursive, which simply means that the function calls itself whilst executing. Those executing functions will then call themselves and so on. This is a more resource heavy way of programming, but since resources tend to be cheap nowadays, recursion is a really neat way of writing code.

Here you can see that factorial will keep calling itself with an update value in the return statement unless a condition is met. If there condition were not there, the application would run indefinitely, with the number of functions being called growing exponentially.
So that will cover functions for this tutorial!
Next time
Next time, we will be looking at header files in C, how to make them and use them in our projects and the benefits they have.