if x …{ else { if x }… }

Read(508) 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.

Parameters:

x

A boolean expression. If the result is true, then execute if code block, otherwise, execute the else or else if code block, if any. If no else or else if code block is available, then the if statement terminates.

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 functions:

if x … else

if x else

if x