Page 46 - 6437
P. 46
value of a is : 10
if…else Statement
An if statement can be followed by an optional else statement, which executes when the
Boolean expression is false.
Syntax
The syntax of an if...else statement in C programming language is:
if(boolean_expression)
{
/* statement(s) will execute if the boolean expression is true */
}
else
{
/* statement(s) will execute if the boolean expression is false */
}
If the Boolean expression evaluates to true, then the if block will be executed, otherwise,
the else block will be executed.
C programming language assumes any non-zero and non-null values as true, and if it is
either zero or null, then it is assumed as false value.
Flow Diagram
48