Limited Control Structures

Every programming language has control structures built into them, which determine the order in which commands are executed. When we speak of limited control structures we are referring to a limited collection of control structures which provide for all the possibilities in a systematic way.

The 3 limited control structures manage the flow of are:

  1. Sequence - in which commands are executed in a linear order. Commands are further organized into blocks.
  2. Branch or Conditional - in which a decision is made about which block of code will be executed. In Java this is achieved with an if…else command.
  3. Loop or Repetition - in which a block of code is repeated. Within this there are specific types of loops:
    1. Count loop - is where a block is repeated a known number of times. In Java this is a for loop.
    2. Conditional loop - is where a block is completed while a condition is true. in Java that is done with either a while command where the condition is tested at the beginning, or a do…until if we want to test the condition after the block has been executed once.

Computer languages offer some other ways of controlling flow through a program, such as a goto command which will cause a jump to a specific destination. Use of these is rarely if ever necessary, and is discouraged, as using these commands can lead to confusing "spaghetti code" which is prone to errors, hard to follow and debug.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License