if x …{ else { if x }… }

Read(1219) Label: if statement, if, else,

Description:

The introduction of if statement.

Syntax:

if  x 

  The if code block

{else {if x}}

  The else or else if code block. When else or else if is not found, then else or else if code block does not exist.

Note:

If the conditional expression x is evaluated as true, then execute the if code block, otherwise, skip the if code block and execute the code block of else or else if.

Parameter:

x

A Boolean expression

Example:

 

A

B

C

 

1

=13

=2

 

C1 returns 7.

2

if(A1>10)

 

 

 

3

 

if(B1==1)

>C1=2+3

 

4

 

else if(B1==2)

>C1=3+4

 

5

 

else if(B1==3)

>C1=4+5

 

6

else if(A1>5)

 

 

 

7

 

>C1=5+6

 

 

Related function:

if x … else

if x else

if x