Gentee Programming Language > Documentation > Syntax Download documentation

Conditional if-elif-else Statement

The statement consists of the following parts:
The if part contains the if keyword, a conditional expression and the block executed if condition is TRUE. If the condition is FALSE, control passes to the next part elif.

The elif part contains the elif keyword, a conditional expression and the block executed if condition is TRUE. The statement is likely to contain some elif parts followed one after another.

The else part contains the else keyword and the block executed if the condition of the if part as well as the condition of all elif parts are FALSE.

The elif and the else operators are optional.

The value of a conditional expression must be numeric. The value is TRUE if it is nonzero.

<if> ::= if <expression><block> {elif <expression> <block>} [else <block>]

//  the if part of the statement
if a == 1
{
b = 10
}
//the if and the else parts of the statement
if a == 1
{
b = 10
}
else
{
b = 0
}
//the statement has all parts: if-elif-else
if a == b+10
{
b = 10
}
elif a == 2
{
b = 100
}
elif a == 3
{
b=1000
}
else
{
b = 0
}


 Copyright © 2004-2006 Gentee Inc. All rights reserved.