Though it explained the method of passing the function the numerical value in the foregoing paragraph
This time, it explains the method of inversely returning the numerical value from the function.
Actually, to have already returned the numerical value, the sum function is made.
Look at the sum function of the foregoing paragraph for the time being.
A noteworthy point is two places.int sum(int min,int max) { printf("%d\n",(min + max) * (max - min + 1) / 2); return 0; }
Another point is return sentence.
Though it has applied without fail without thinking about the current, especially anything at the end of the function
Actually, the function of returning the numerical value to this return sentence is provided.
In a word, this sum function is a numerical value of the int type 0 was supposed to be returned.
Such a numerical value that comes back from the function might be called a return value (function value).
It is necessary to substitute it for the variable to know the return value in the call origin.
[ Return value ]
Numerical value returned from function.
It is often an numerical value that shows the presence of the numerical result or the error.
Not only display the numerical result but also if you use this return valuevalue = sum(50,100);
The execution result of this program becomes as follows.#include <stdio.h> int sum(int,int); /* Prototype declaration */ int main(void) { int value; value = sum(50,100); printf("%d\n",value); return 0; } int sum(int min,int max) { int num; num = (min + max) * (max - min + 1) / 2; return num; }
This sum function only returns the numerical result though ahead nor the result change.
3825
In the argument explained in the foregoing paragraph, two or more arguments were able to be used.
Curettage is not effective though I want to say Then, even the return value : naturally ・・・.
Very, only one return value can be returned.
The return value has only the resignation by one because it becomes it so.
Actually, postpone this though there is [waza] to which the numerical value is returned by the argument, too.
Though it was necessary to specify when calling it for the argument
You may disregard the return value.
To tell the truth, though the printf function also returns information how many characters to have displayed
Frankly speaking, because it is information with a good such throat a boil, it has been disregarding it.
The type that it likes double besides int can be used also for the return value.
Moreover, it is also possible to make the function that doesn't return the return value.
In that case, specify void ahead of the argument name.
There are unexpectedly a lot a return value unnecessary if it is very a very simple function.