CONTROL
STATEMENT
Control statement refers to the statement or
command used to change the order of
execution of statements or repeat a group of
statements until a certain specified
conditions are met .
They are categorized into the following :-
• Branching statement
• Looping statement
CONTROL
STATEMENT
Branching Looping
Statement Statement
Unconditio Condition
nal al 1.FOR..NEXT
Branching Branchin 2.DO.. WHILE
g 3.WHILE…
• IF..THEN
Like WEND
• IF…ELSE
GOT • IF ..ELSEIF
O …
Branching
STATEMENT
Branching statements are the statement
used to jump the flow of execution from
one part of program to another . It affects
program sequence by transferring the
control to the labeled statement .
There are two types of branching
statements :-
• Unconditional Branching
Unconditional
Branching
It transfers the control flow directly without
testing any conditions from one statement
to another in a program .
GOTO
GOTO statement tells the program to
go to another place in the program directly
.
SYNTAX :
Conditional
Branching
It executes a block of statement or
statements depending upon the condition
passed upon the value of an expression
IF….THEN
IF…THEN statement is used to perform
the operations based on some specific
condition .
SYNTAX :
IF….THEN….ELSE
IF…THEN…ELSE is used to execute a
statement or block of statement if the if
condition is true otherwise else statement will
be executed .
SYNTAX :
IF<condition> THEN <statement1>ELSE
<statement2>
IF….ELSEIF…ENDIF
IF…ELSEIF…ENDIF is used to execute a
statement or block of statement if the if
condition is true or ELSEIF condition will be true
then statement 2 will be executed otherwise
ELSE statement will be executed.
SYNTAX :
IF<condition> THEN <statement1>
ELSEIF<condition2>THEN
<statement2>
SELECT CASE…END SELECT
SELECT CASE…END SELECT statement is control
flow statement that executes one of the several
statement blocks depending upon the value of
an expression .
SYNTAX : SELECT CASE <expression>
CASE 1
statements
CASE 2
statements
CASE ELSE
statements
LOOPING
STATEMENT
Looping is the process of repeating the
execution of a statement or block of
statements guided by a condition. The loop
is terminated when the given condition is
satisfied .
• DO….LOOP WHILE statement
• WHILE…WEND
• FOR….NEXT
DO…LOOP
WHILE ..
In this statement DO caries statement
to be done while the condition will be
within while and it gets repeated until
the condition is false .
Syntax:
DO
<statements >
LOOP WHILE <
condition >
DO…LOOP
WHILE ..
WHILE .. WEND
In this statement, if the condition in the while
satisfies then the statement will run otherwise
end .
Syntax:
WHILE <condition>
<statements >
WEND
WHILE .. WEND
FOR ….NEXT ..
In this statement, if the condition in the FOR
satisfies then the statement will run and repeat
through the next statement and if the condition
gets false the program will end .
Syntax:
FOR <counter = start to end>
<statements >
NEXT counter