Function&Recursion in C

C PROGRAMS ON FUNCTION AND RECURSION

C program has at least one function, which is main(),  programs can define additional functions.Functions are generally used so that if we have a program performing separate tasks then each task can have a separate function so that code readability is increased and can also be used for reusability that is if we want the same code to be written then we do not need to write the whole code again, we just need to call that function.

For example, if we want to write a program for a tourism site then we can have one function for booking tickets, a function for displaying the packages, a function for calculating costs and a function for displaying the total bill with all the details.So multiple persons can work on a single project and then integrate the functions to make it a proper working project.

As for recursion, it is nothing but a function calling itself. It is a very powerful method for solving complex problems, as sometimes coding these complex problems using iterative approach might be a herculean task.You will get a more clear picture once you dive into data structures as you will notice that coming up with a recursive solution is much easier than coming up with an iterative one for the same problem.

Share Me!
  •  
  •  
  •  
  •  
  •  
  •