Function Calling in C Programming (Complete Guide with Examples)
This tutorial explains how to call functions in C. It covers syntax, examples, and the flow of execution, helping beginners understand how functions are used to make code modular, reusable, and organized.
1. What is Function Calling
Function calling is the process of executing a function from another function (usually main()).
When a function is called:
- Program control jumps to the function
- Executes the code inside the function
- Returns to the calling point
2. Syntax
function_name– Name of the functionarguments– Values passed to the function (optional)return_value– Variable to store the result (if return type is notvoid)
3. Example: Calling a Function with Return Value
Sample Output:
4. Function Call Without Return Value
If the function does not return any value, use void as return type.
Output:
5. Function Call with Arguments
You can pass values to a function using arguments.
Sample Output:
6. Key Points to Remember
- Functions must be declared before calling (or use prototypes)
- Arguments can be passed by value or reference (call by value/reference)
- Functions help modularize code and avoid repetition
voidfunctions do not return values, but can perform actions