Home >Backend Development >C++ >The difference between actual parameters and formal parameters in C language
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:
<code class="c">int sum(int a, int b) { return a + b; }</code>
a
and b
It is a formal parameter and a placeholder variable. When calling a function, the actual parameters are passed to the formal parameters:
<code class="c">int x = 5, y = 10; int result = sum(x, y);</code>
x
and y
are actual parameters, use to actually pass to the function. a
and b
will receive the values of x
and y
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!