Function parameters are variables declared in a function’s parameter list. They receive the values supplied through arguments when the function is called.
#include <stdio.h>
int multiply(int a, int b)
{
return a * b;
}
int main(void)
{
int result1 = multiply(4, 5);
int result2 = multiply(6, 3);
printf("%d\n", result1);
printf("%d\n", result2);
return 0;
}
Example Output #
20
18
Explanation #
The function definition declares two parameters:
int multiply(int a, int b)
Here, a and b are parameters of type int. Each call supplies two argument values.
multiply(4, 5);
multiply(6, 3);
During the first call, a receives 4 and b receives 5. During the second call, a receives 6 and b receives 3.
Parameters and Arguments #
| Term | Example | Meaning |
|---|---|---|
| Parameter | int a |
Variable declared in the function definition |
| Parameter | int b |
Second variable declared in the function definition |
| Argument | 4 |
Value supplied by the caller |
| Argument | 5 |
Second value supplied by the caller |
Functions with Different Parameter Lists #
A function can accept multiple parameters of different types:
double calculateArea(double length, double width)
{
return length * width;
}
It can also accept no parameters:
void display(void)
{
printf("Ready\n");
}
In a function definition, void inside the parentheses explicitly indicates that the function accepts no parameters.
The number and types of arguments must be compatible with the function’s declared parameter types. C passes argument values to parameters; it does not automatically provide reference-style parameter passing.