Professional Documents
Culture Documents
Gerald L. Almodiel
If Statement
If…Else Statement
If…Else…If Statement
Switch Statement
Sample Programs
If Statement
An if statement consists of a boolean
expression followed by one or more
statements.
e.g.
if ( condition )
{
statement1;
statement2;
}
If…Else Statement
An if statement can be followed by an
optional else statement, which executes
when the boolean expression is false.
e.g.
if ( condition)
statement1;
else
statement2;
If…Else If Statement
An if statement can be followed by multiple
if else statement, which executes when the
boolean expression is false.
e.g.
if ( condition )
statement1;
else if ( condition )
statement2;
else if ( condition )
statement 3;
:
:
Switch Statement
A switch statement allows a variable to
be tested for equality against a list of
values.
e.g
switch( variable ){
case 1:
case 2:
default:
}
If Statement
If…Else Statement
If…Else If Statement
Switch Statement
ANY QUESTIONS ?
~ FIN