English
Language : 

CC78K0S Datasheet, PDF (130/520 Pages) NEC – C Compiler Ver.1.30 or Later Language
CHAPTER 6 CONTROL STRUCTURES OF C LANGUAGE
(4) return statement
Branch Statements
return
FUNCTION
A return statement exits the function that includes the return and passes controls to the function that called the
return, and calls and returns the value of the return statement expression as the value of the function call
expression. Two or more return statements may be used in a function. Using the closing brace “ } ” at the end
of a function produces the same result as when a return statement without an expression is executed.
SYNTAX
return expression ;
EXAMPLE
int f(int);
void main(void){
/*...*/
int i=0,y=0;
y=f(i);
/*...*/
}
int f(int i){
int x=0;
/*...*/
return(x);
}
EXPLANATION
In the above example, when control is passed to the return statement, the function f() returns a value to the
function main. Because the value of the variable “x” is returned as the return value, the assignment operator
causes the variable “y” to be substituted with the value of the variable “x”.
NOTE
With a void type function, an expression that indicates a return value cannot be used for a return statement.
130
User’s Manual U14872EJ1V0UM