0% found this document useful (0 votes)
3 views2 pages

Control Structures2

The document outlines the three fundamental control structures in structured programming: sequence, selection, and iteration. It explains that a structured program can be defined using these constructs, as demonstrated by Bohm and Jacopini's findings in 1964. Examples are provided, including a payroll algorithm illustrating sequence, pseudocode for selection, and the concept of iteration through loops.

Uploaded by

khart8373
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

Control Structures2

The document outlines the three fundamental control structures in structured programming: sequence, selection, and iteration. It explains that a structured program can be defined using these constructs, as demonstrated by Bohm and Jacopini's findings in 1964. Examples are provided, including a payroll algorithm illustrating sequence, pseudocode for selection, and the concept of iteration through loops.

Uploaded by

khart8373
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Control Structures

Sequence
Selection
Iteration

A structured program is defined by D'Orzio (1990) as:

A computer program which is implemented using only those


control structures which are found in structured program
designs.

What makes a program design structured? In 1964, Bohm and Jacopini published a paper
which demonstrated that any problem can be solved by using the three logic control
structures of sequence, selection and iteration (or repetition). The three structured
programming constructs are illustrated in flowchart and statement form below.

Sequence

The sequence control structure consists of processes which are carried out in a sequential
manner:

STATEMENT A
STATEMENT B
STATEMENT C
Our Do Payroll algorithm is an example of a simple sequential control structure.

Sequence Control Structure

Major Tasks: Do Payroll

DO Enter Pay Details


DO Calculate Pay
DO Print Pay Details
DO Update Employee Records

Subtask: Enter Pay Details

INPUT employee name


INPUT weekly hours
INPUT rate of pay

Subtask: Calculate Pay

CALCULATE gross = hours * rate


CALCULATE tax = gross * .23
CALCULATE net = gross - tax

Subtask: Print Pay Details

PRINT employee name


PRINT gross
PRINT tax
PRINT net

Subtask: Update Employee Record

OPEN employee record


WRITE employee pay details
UPDATE year to date figures

Selection

The selection control structure consists of a condition which is either True or False.
Processes will be carried out depending on the result of the condition test.

In pseudocode, selection is represented by the IF, THEN, ELSE, and ENDIF statements.

IF Condition is true THEN


DO Process A
ELSE
DO Process B
ENDIF
Using our Morning Routine algorithm, we can apply the selection control structure to the
Take a Shower task.

Iteration

The iteration control structure consists of actions that need to be repeated over and over again
while a particular condition is true. This is the concept of the LOOP.

In pseudocode, iteration is represented by the WHILE and ENDWHILE statements.

WHILE Condition is true DO


Process statements
ENDWHILE
We can apply the iteration control structure to the major tasks of our Do Payroll algorithm.

You might also like