English
Language : 

CC78K0S Datasheet, PDF (120/520 Pages) NEC – C Compiler Ver.1.30 or Later Language
CHAPTER 6 CONTROL STRUCTURES OF C LANGUAGE
(1) if and if ... else statements
Selection Statements
if, if ... else
FUNCTION
An if statement executes the statement that follows the control expression enclosed in parentheses if the value
of the control expression is nonzero.
An if ... else statement executes the statement-1 that follows the control expression if the value of the control
expression is nonzero or the statement-2 that follows else if the value of the control expression is zero.
SYNTAX
if (expression) statement
if (expression) statement-1 else statement-2
EXAMPLE
unsigned char uc;
void func (void){
if( uc < 10 ){
/* 111 */
}
else{
/* 222 */
}
}
EXPLANATION
In the above example, if the value of uc is less than 10 based on the control expression in the if statement, the
block “{/*111*/}” is executed. If the value is greater than 10, the block “{/*222*/}” is executed.
NOTE
When the processing after if statement/if...else statement is not enclosed with “{ }”, only the processing of one
line after the if statement/if...else statement is performed regarding it as the body.
120
User’s Manual U14872EJ1V0UM