ProgrammingStructures
ProgrammingStructures
333/443
Programming Control Structures refer to the way computer instruction flow is managed. In principle, instructions are
executed one after another, in the same way they were stored in the computer memory (von Neumann’s model).
However, computing solutions hardly require strictly sequential programs, instead, some instructions have to be executed
conditionally and many others have to be repeated several times.
1. Sequence,
2. Selection, and
3. Iteration.
Computer languages with statements that directly implement those structures are known as structured languages.
For example, in C or C++, a sequence of instructions is denoted by the symbols { and }, the selection of actions occurs
with the statement if, or if-else, and iteration is accomplished with the loops for, while, and do-while.
Assembly languages are not structured in the sense that they do not provide specific instructions to control instruction-
flow; however, that is easily implemented, and is an essential feature of any language compiler. At this point, the
flowcharts corresponding to each structure result quite useful for the compiler designer or assembly programmer..
Computer Systems Fundamentals 600.333/443
(Abridged section)
int main ()
next: // next
nop ; replace by instruction 2 function2();
if (t0==0)
function1();
function2();
function3(); // next
j loop }
exit: //exit
nop ; replace by instruction n