When we begin programming in C/C++, we generally write one main() function and write all our logic inside this. This approach is fine for very small programs, but as the program size grows, this become unmanageable. So we use functions. We write code in the form of functions. The main function always acts as a driver function and calls other functions.
We can also write function call as a parameter to function. In the below code, first add(num1, num2) is evaluated, let the result of this be r1. The add(r1, num3) is evaluated. Let the result of this be r2. Finally add(r2, num4) is evaluated and its result is printed.
Another example of function calling function are as follows : –
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- How to call some function before main() function in C++?
- A C/C++ Function Call Puzzle
- Can we call an undeclared function in C++?
- Difference between Call by Value and Call by Reference
- Difference between user defined function and library function in C/C++
- Function Overloading vs Function Overriding in C++
- Wait System Call in C
- pipe() System call
- Accept system call
- dup() and dup2() Linux system call
- Is it possible to call constructor and destructor explicitly?
- Order of Constructor/ Destructor Call in C++
- What happens when a virtual function is called inside a non-virtual function in C++
- Difference between Virtual function and Pure virtual function in C++
- arc function in C
- exp() function C++
- log() function in C++
- fma() function in C++
- div() function in C++
- wcscat() function in C++
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.