The topic for the day is about Function & Recursion. I’m gonna write the basics only. If you want to know more, search it on Google or Wikipedia or any other website that might provide you with the necessary information that you inquire.
Moving on…..
Programs are divided into modules. This is where functions comes in. Functions are for implementing modules in programming.
Function itself is formed by grouping several statements for a designated purpose.
Mind you, functions are divided into two:
- Library Function. This is a ready-to-use one, provided by C Compiler.
- User-defined Function. You already what this means. It means functions that are made by the user.
I won’t go into more details on function. Moving on to Recursion.
Recursion is a function that could call itself repeatedly. This type is usually found in certain functions only. It is useful for recursive problems & Fibonacci sequence.
There is one rule when you want to use your own function. That is: place it above int main. This is due to the fact that main will only run the functions before it, thus making a custom function useless should one not place it above int main.
For more details, search for it online. Like I said, I don’t wanna write too long. It’s a pain.