Master ()
{
int n;
Printf ("Enter number \ n");
scanf("%d ",& ampn);
s(n);
printf("n=%d\n ",n);
}
Integer s (integer n)
{
int I;
for(I = n- 1; I>= 1; I-)
n = n+I;
printf("n=%d\n ",n);
}
A function S is defined in this program, and its function is to find the value of ∑ni. Enter the value of n in the main function, and pass it as an argument to the formal parameter n of the S function when calling (note that in this example, the identifiers of formal parameter variables and argument variables are both n, but they are two different quantities with different scopes). In the main function, the printf statement is used to output the value of n once, that is, the value of independent variable n, and in the function S, the printf statement is also used to output the value of n once, that is, the final value of n obtained by formal parameters is 0. Judging from the running situation, the input value of n is 100. That is, the value of parameter n is 100. When this value is passed to the function S, the initial value of the formal parameter n is also 100, and the value of the formal parameter n becomes 5050 during the execution of the function. After returning to the main function, the value of the output parameter n is still 100. It can be seen that the value of real parameters does not change with the change of shape parameters.
8.3.2 function return value
The value of a function refers to the value obtained by a program segment in the execution function body and returned to the calling function after the function is called. For example, call the sine function to obtain the sine value, and call the max function of Example 8. 1 to obtain the maximum number. There are some explanations about the function value (or function return value):
The value of 1) function can only be returned to tonic function through return statement.