Code: Select all
return-type function-name(declarations)
{
declarations
statements
return expression;
}
Return expression
There need to be no expression after return; in that case, no value is returned to the caller. Control also returns to the caller with no value when execution "falls off the end" of the function by reaching the closing right brace. It is not illegal, but probably a sign of trouble, if a function returns a value from one place and no value from the other. In any case, if a function fails to return a value, its "value" is certain to be garbage.
2) What do they mean by this, and when should you use return and when should you not?
3) If the return-type is ommited, int is assumed like in:
Code: Select all
main()
{
}