The actual parameters are the actual values passed when the function is called, while the formal parameters are placeholder variables declared in the function definition to receive the actual parameter values. The actual parameters are determined when calling, and the formal parameters are determined when defining; the actual parameters can be changed, but the formal parameters can only be modified within the function body.
The difference between actual parameters and formal parameters in C language
In C language, the difference between actual parameters and formal parameters Parameters are two important concepts in function calls, and there are key differences between them.
Actual parameters
Formal parameters
Difference
The main difference is:
Example
Consider the following function definitions:
int sum(int a, int b) { return a + b; }
a
andb
It is a formal parameter and a placeholder variable.When calling a function, the actual parameters are passed to the formal parameters:
int x = 5, y = 10; int result = sum(x, y);
x
andy
are actual parameters, use to actually pass to the function.a
andb
will receive the values ofx
andy
respectively.The above is the detailed content of The difference between actual parameters and formal parameters in C language. For more information, please follow other related articles on the PHP Chinese website!