3. IF STATEMENT
If statement executes a block of
statement based on a logical
Boolean condition.
• if this condition is true the
block following the statement
is executed.
• If the condition is false the
block after the if statement is
not executed and after
statement block is executed.
4. IF-ELSE STATEMENT
Sometime If is required to
define a block of statement to
be executed when a condition is
evaluated to false. This is done
using the if-else statement.
if else statement begins with the
If Block which is followed by the
else block
5. IF-ELSE IF STATEMENT
If else statement allows you to check
multiple condition and specify a different
block to be executed for each condition.
The flow of these statements begins with
the If statement followed by multiple else
If statement and finally by an optional
else block
If the condition in the If statement is false
the condition in the immediate else If
statement is evaluated
6. SWITCH-CASE STATEMENT
A program becomes quite
difficult to understand when
they are multiple if statements
to simplify coding Switch-case
statement is used.
This statement allows
comparing a variable or
expression with multiple values.
8. WHILE LOOP
The while loop executes a block
of code as long as the given
condition remains true.
The while loop begins with while
keyword which is followed by
parentheses containing a
Boolean condition.
9. FOR LOOP
The for loop is similar to while
loop in functionality It executes
the statements within the loop
as long as the given condition is
true.
Unlike while loop the for loop
specifies the loop control
statements at the top instead in
the body of the loop.
10. DO-WHILE LOOP
The do-while loop is similar to
while loop This is because both
the do-while and while loops
execute until the condition
becomes false.
However the do-while loop
executes the body of loop at
least once before evaluating the
condition.