Datasheet
RETURN STATEMENT
The return statement is used to exit from the current function back to the calling
routine, optionally returning a value. The syntax is:
return [expression];
This will evaluate expression and return the result. Returned value will be automat-
ically converted to the expected function type, if needed. The expression is option-
al; if omitted, the function will return a random value from memory.
Note: The statement return in functions of the void type cannot have expression
– in fact, the return statement can be omitted altogether if it is the last statement
in the function body.
COMPOUND STATEMENTS (BLOCKS)
The compound statement, or block, is a list (possibly empty) of statements enclosed
in matching braces { }. Syntactically, the block can be considered to be a single
statement, but it also plays a role in the scoping of identifiers. An identifier declared
within the block has a scope starting at the point of declaration and ending at the
closing brace. Blocks can be nested to any depth up to the limits of memory.
For example, the
for loop expects one statement in its body, so we can pass it a
compound statement:
for (i = 0; i < n; i++ ) {
int temp = a[i];
a[i] = b[i];
b[i] = temp;
}
Note that, unlike other statements, compound statements do not end with semicolon
(;), i.e. there is never a semicolon following the closing brace.
217
MIKROELEKTRONIKA - SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Language Reference
mikroC PRO for AVR
CHAPTER 5