Control structure

       If you look through a program, it can seem like one long story. Lines, that are written in a certain order. But they are not always run in the same order as they are written, and some of them may not run at all. We use control structures as one of the mechanisms to control how the program runs. These structures also help programs be smaller and be easier to understand and correct.
       Control structures are grouped together in sequence, selection and iteration. Sequence is the easiest - one line follows the next. Selection is like a choice - do we go left or right? Should we do something or not? "If" and "branching" are both examples of selection. Iteration is, that a piece of program can run 0, 1 or more times, depending on the circumstances. "For" and "while" are examples of iteration.
       When we talk about iteration, we also often talk about loops - a for loop e.g. When it has to be decided e.g. whether a selection should do one thing or another, we do it by examining the circumstances - very often by comparing two numbers or something similar. In this connection it is necessary to have operators to do the comparison - they could e.g. look like this:

== != < > >= <=
       And in English are called: "equals", "doesn't equal", "less than", "greater than", "greater than or equal" and "less than or equal". It could be part of a program like this:
if numberOfFields > numberOfHits
  write "This ship is stille here"

Concept last updated: 06/05 2004.

Relations

is a kind of
is a kind of
is a kind of
is a kind of
is a

Other sources

Computer Control structure Create, alter, drop

Libellus