A. Sequence
- The sequence control structure is the simplest of all basic control structures. In a sequence, statements are executed in order, one after another, as the sequence states. It is simply a series of statements with no decision making, looping, or branching. Sequences are like a straight line. There can be as many statements as you would like in a sequence as long as they are executed one after the next in the order determined by the programmer that wrote the Sequence.
B. Selection (Decision, If Then/Else) – A Selection Control structure is a structure that provides a decision when a question is asked. Selection is limited to a true or false / yes or no statement. When a question proves to be true then a statement or a sequence of statements will be executed. When a question proves to be false a different statement of sequence of statements will be executed. The If Then/Else statement is similar. If something is true than a certain statement or sequence will be executed, if it is false than nothing will be executed and that statement or sequence will be skipped. The Case Control structure is presented when you need an option for more than two alternative results. It is basically an extended form of the Selection structure.
C. Loop (looping, iteration) – A loop is a control structure that executes statements repeatedly. Loops contain three basic parts: a loop termination decision (determines when the loop will terminate), the body of the loop (the statements that are repeated in the loop), and a transfer to the beginning of the loop (returns control to the top of the loop, beginning a new iteration). The two basic types of loops are the Pre-test Loop and the Post-test Loop. A Pre-test Loop executes the loop termination decision first. If conditions are favorable to execute the body of the loop, those statements are executed followed by a transfer to the beginning of the loop (the loop termination decision). A Post-test Loop executes the body of the loop first, followed by the loop termination decision. If conditions are favorable a transfer to the beginning of the loop is executed, followed by an iteration of the body of the loop.
Pre-Test Loop Post-Test Loop
D. Unconditional Branch (GOTO) – A Unconditional Branch Control Structure or GOTO Statement is a simple statement. There is no decision to be made. Basically it instructs the computer to jump to a specified label or line of code unconditionally (no matter what). Most high-level languages use the GOTO instruction followed by a destination to perform this operation. Similarly, a Conditional Branch Control Structure provides the same GOTO instruction but it is based on a Boolean (true/false) condition. If the condition is true the GOTO instruction is followed, if the condition is false it does not. The constructs of modern programming and the Control Structures listed above virtually eliminate the need for GOTO statements. Today, GOTO statements are mostly required when writing error-handling code.
Pre-Test Loop Post-Test Loop
D. Unconditional Branch (GOTO) – A Unconditional Branch Control Structure or GOTO Statement is a simple statement. There is no decision to be made. Basically it instructs the computer to jump to a specified label or line of code unconditionally (no matter what). Most high-level languages use the GOTO instruction followed by a destination to perform this operation. Similarly, a Conditional Branch Control Structure provides the same GOTO instruction but it is based on a Boolean (true/false) condition. If the condition is true the GOTO instruction is followed, if the condition is false it does not. The constructs of modern programming and the Control Structures listed above virtually eliminate the need for GOTO statements. Today, GOTO statements are mostly required when writing error-handling code.