※スタイルシート未対応ブラウザではレイアウトを正確に再現できません。
> | advanced by | contents  | that returns in <
< [modosusu] > Color magazine monochrome light and shade   font predetermined, Gothic Ming-style type longhand   size Konaka large   standard

Pass the function the numerical value.

1. ..clause 1..: Function with argument
2. ..clause 2..: Pass the function the numerical value.
3. ..clause 3..: Two or more arguments

[1] Function with argument

The sum function was made from the preceding clause, and the calculation of the total of 1-100 was made parts.
However, it is inconvenient in only total of 1-100 computable.
It is convenient to be able to calculate the total of a freer range.

Information (numerical value) can be passed to the function for such time.
It is a mechanism that the mechanism for that is called an argument.
The numerical value can be passed to the function by using the argument.

[   Argument   ]
Generic name of information passed to function
The argument should be written in () of the function and be specified.
In the sum function made in the preceding clause, the argument was void.
Specify this void when you do not use the argument.

When the argument is used, the variable that stores the passed numerical value is declared in ().
Make it to as follows when you store the numerical value in variable max of the int type by the sum function.

``` int sum(int max);
```
Thus, the part where the variable used is specified is called a dummy argument.

[   Dummy argument   ]
Type and name of argument written in function declaration
Though it is necessary to do the prototype declaration similarly when the function is changed
Do not omit the variable in the prototype declaration and do not care even about a type alone.
The following program is an example of remodeling the sum function to receive the argument.
```
#include <stdio.h>

int sum(int); /* Prototype declaration */

int main(void)
{
return 0;
}

int sum(int max)
{
printf("%d\n",(1 + max) * max / 2);
return 0;
}
```
The variable specified for the argument can be used in the function just like a usual variable.

It returns to contents.

[2] Pass the function the numerical value.

When the function with the argument is called, it is necessary to pass the numerical value.
Write the numerical value in () in it when calling it.
The following program is an example of passing the numerical value of 50 to the sum function.
The numerical value passed to the function might be called an actual argument.

[   Actual argument   ]
Numerical value passed when function is called
```
#include <stdio.h>

int sum(int); /* Prototype declaration */

int main(void)
{
sum(50); /* */ to which 50 has been
passed  Return 0;
}

int sum(int max)
{
printf("%d\n",(1 + max) * max / 2);
return 0;
}
```
The execution result of this program is as follows.

1275
The numerical value of 50 specified when the sum function is called : this.
It is substituted for variable max that is the dummy argument of the sum function.
Naturally, the display result changes, too, when the numerical value when the sum function is called is changed.

Pass the numerical value when you call the function with the argument.
For instance, if the function is called, it becomes an error following sum.

```
sum();
```

It returns to contents.

[3] Two or more arguments

There is no argument because of being limited only to one.
The function where only liking it has the argument can be made if it is necessary.

To make the sum function a function from which the total value of min-max is requested
It is possible to achieve it by expanding the argument into two, and replacing the expression of contents.
The following function is an example of remodeling to request the total of min-max.

``` int sum(int min,int max)
{
printf("%d\n",(min + max) * (max - min + 1) / 2);
return 0;
}
```
Switch off and specify of each in [de] district when you use two or more arguments.
There is no problem even if another type is mixed though the int type is used for both here.

Switch off and specify the numerical value in [de] district when you call this function.
The actual argument and the dummy argument correspond by couple 1 as it is the array order.
The following program is an example of calling the improved sum function.

```
#include <stdio.h>

int sum(int,int); /* Prototype declaration */

int main(void)
{
sum(50,100);
return 0;
}

int sum(int min,int max)
{
printf("%d\n",(min + max) * (max - min + 1) / 2);
return 0;
}
```
The execution result of this program is as follows.

3825
The prototype declaration is corrected.
Moreover, if the numerical value is not passed to all the arguments, it is not possible to call it by the function with two or more arguments.

It returns to contents.

< - It is advanced -> | in | head that returns  to returning  next |.