Professional Documents
Culture Documents
Chapter 10
Chapter 10
Control statements are used to change the flow of execution of the statements of a program, by
repeating or skipping a few statements, subject to a given condition. They are very helpful in making
decisions at run time.
Branching
Looping
Subroutines
Branching Statements
If Then Statement
Syntax :
If <Condition> Then
<Statements>
EndIf
Example :
Textwindow.writeline(“Number is positive”)
Endif
Example:
The If Then Else statement is another branching statement, also called the Bi – Directional decision-
making statement, which is executes both the statements i.e. of both the True and False conditions.
Syntax:
If <Condition> Then
<Statement 1>
Else
<Statement 2>
EndIf
Example:
Textwindow.writeline(“Number is positive”)
Else
Textwindow.writeline(“Number is negative”)
Endif
The Goto statement is an unconditional transfer control.It is used to transfer the program control
from one statement to another in a program.
Syntax:
Goto <Label>
Example :
Goto Start
Start is a label.
Example :
A=1
Start :
B=A*A
Textwindow.writeline(B)
A=A+1
Goto Start
Goto with If then is used when a decision has to made about where the program control should go
next.
Syntax :
Label :
If <Condition> Then
<Statement(s)>
Goto Label
EndIf
Example :
J=0
Start :
J=j+1
If ( j < 10 ) Then
Goto Start
EndIf