Please enable JavaScript.
Coggle requires JavaScript to display documents.
CONTROL FLOW - Coggle Diagram
CONTROL FLOW
Flow of control among statements
Iterative Statements
Simple Repetition
Statement head specifies that the body is to be executed some fixed number of times.
Main issues
Can K be reevaluated in the body causing the number of iterations to be changed
What will happen if K is zero or negative
Counter-Controlled Loops
Has a variable : loop variable
Some means of specifying the initial and terminal values of the loop variable, and the difference between sequential loop variable values: step-size
Design issues
Type and scope of the loop counting variable ?
Is the loop variable defined upon exiting the loop ?
Can the loop variable or loop parameters be changed inside the loop ?
Is the test for the completion placed at the top or the bottom of the loop ?
Are the loop parameters evaluated on every situation ?
Logically-Controlled loops
Repetition control is based on a boolean expression
Every counter controlled loop can be built with a logically controlled loop, but not the converse.
Design issues
Should the boolean expression be tested before or after the execution of the loop body ?
C's for structure can easily model both counting and logical loop structures.
User-located loop control
Several languages have loop statements that have no iteration control mechanism; they are infinite loops unless controls are added by the programmer.
Any loop can be labeled, and when a loop label is included on the exit, control is transferred to the statement immediately following the referenced loop.
When neither of optional parts are defined, exit causes the termination of only the loop in which it appears.
Iteration based on data structures
Rather than a counter or boolean expression controlling the iteration, a data structure is used to control the iteration
User-defined iteration control
A more general databased iteration statement users a user-defined data structure and a user-defined function, called an iterator, to go through the structure's elements
Control Statements
Control Structures
Break Statements
Causes control to move forward in the program to an explicit point at the end of a given control structure
Continue Statement
Causes control to move forward in the program to an explicit point at the end of a given control structure.
Evolution of control statements
Instructions
Gotos
Common forms of statement-level sequence control
Composition
Alteration
Iteration
Labels
An explicit name or number assigned to a fixed position within the source code
Maybe referenced by control flow statements
Selection Statement
Single-way
Two-way
N-way
Flow of control within expressions
Flow of control among program units