Monday, April 11, 2011

Basic Structures

The four basic control structures are sequencing, unconditional branches, loop, and selection. A structure is a basic unit of programming logic.  A structure is a basic unit of programming logic.
Sequencing is a program structure that execute in order with no option of branching to skip or repeat any of the tasks. In a sequence structure an action or event primarily leads to the next step the order. The sequence can complete any number of actions, but there is no way of skipping a step in the process. When the program is eventually run it must complete the steps in order. An example of a sequencing structure would look something like this.


Selection structure, also known as decision structure is where one would ask a question, and depending on the answer there can be one of two answers. After the decision is made and the path is chosen the task continues on to the next step. An easy way that people describe selection structure is with the "if then else" rule. An example would be "if some condition is true then do one process, else do the other process." Basically any structure that is selection must contain both a decision symbol, and the decision of the branches must join at the bottom of the structure.

Loop structure is the third of the basic structures, and obviously by the name the process is repeating. In a loop structure the process repeats and continues to repeat the listed steps as long as the condition remains true. The steps included in the loop are known as the loop body. The most common type of a loop would have a condition that is listed, and if the result of the evaluation of the condition is true then the step is executed again. If the condition keeps coming back as true until the evaluation comes back false. Once the condition is false than the structure is exited.

An unconditional branch would be a sequence of code in a computer program which is executed under any conditions in the sequence of code. It can be altered at the branching point in a sequence and will redirect the sequence to another task or function and it will then complete the task and return to the main sequence. It should not be confused with a loop. Loops are repeating a condition over and over until the result is false, an unconditional branch will perform the function only once and then continue on with the rest of the structure of code.


Using the four basic structures in computering programming will allow you to accomplish anything from simple programs, to brain surgery. It is also important to understand all of the different structures as they are extremely important in the world of computer programming.