Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - Differences and Relations between Function Form and Real Parameter in C Language
Differences and Relations between Function Form and Real Parameter in C Language
In essence, formal participation in real arguments is two different things.

For example, the function f(x)=y=x? +2x, x is the parameter of the function, and we write it in C language:

flotage

F (floating

x)

{

flotage

y;

y = x * x+2 * x;

return

y;

}

Do you think it is different from f(x)=y=x? How similar +2x is!

When we want to calculate the function value of f(2), let x=2 and get y=8, that is, f(2)=8.

Here in the C language, we call X "formal parameter" and 2 "actual parameter", which shows how different the two are!

If there is a variable a= 1, you can also calculate f(a)=2. In fact, when calculating, the value of A is assigned to X, and A is a real parameter, and X is a formal parameter. The value of a has not changed before and after calculation.

If the program calls: c=f(a)+f(2), the result is c= 10.

It is worth noting that real parameters often use the same letter, such as both X, but these two X are different variables. After the real parameter x assigns a value to the formal parameter x, the real parameter is nothing, and the change of the formal parameter x value in the function will not affect the value of the real parameter X.

Speaking of their similarities, their variable types are the same; When it comes to their relationship, there is the assignment of real parameters to shape parameters; Speaking of their differences, they are two different variables.

A lot of verbosity, I don't know if it's clear. If anything is unclear, please leave a message.