Chapter # 3Control Structure
Q .Define control structure. How many control structures are available in BASIC.
Discuss briefly.
Control structure
Control structure is used to control the flow of execution of a program.
Control structures in BASIC
There are 3 types of control structure in BASIC.
1)Sequence control structure.
2)Selection control structure.
3)Repetition control structure.
Sequence Control Structure
In this structure, code is executed in the same order in which it is written. No
line is skipped. It is mostly used structure.
Selection Control Structure
In this structure, code is executed depending upon the condition. One block of
code will be executed and other block will be skipped.
Example:
IF-THEN
IF-THEN-ELSE
ONGOTO
Repetition Control Structure
In this structure, code is executed again and again until given condition is true.
Example:
FOR NEXT LOOP
WHILE WEND LOOP
What is control transfer? What are its types?
Control transfer
Control transfer means moving control from one place to another Place in the
program. It has 2 types.
Unconditional
Conditional
Unconditional control transfer
In this transfer, control moves from one point to other specific point by skipping
one or more lines without any condition.
Example:
GOTO Statement
Conditional control transfer
In this transfer, control moves from one point to other specific point by skipping
one or more lines depending on a certain condition.
Example:
ON GOTO Statement
IF-THEN-ELSE Statement