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 : –
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- 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
- Accept system call
- pipe() System call
- dup() and dup2() Linux system call
- Order of Constructor/ Destructor Call in C++
- Is it possible to call constructor and destructor explicitly?
- Difference between Virtual function and Pure virtual function in C++
- What happens when a virtual function is called inside a non-virtual function in C++
- fma() function in C++
- arc function in C
- log() function in C++
- exp() function C++
- div() function in C++
- Inline 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.