Three Basic Structures Of Structured Programming

1073 Words3 Pages

INTRODUCTION

Structured programming is one of the several different ways in which a programming language can be constructed. "It was originally introduced as a means of getting away from the 'spaghetti' code that was used in the early days and to provide some means by which programmers could more easily follow code written by other programmers." (Hendren, 1998) Structured programming is a procedure-oriented method of designing and coding a program.

At a low level, structured programs are composed of simple, hierarchical program flow structures. "These are regarded as single statements, and are the same time ways of combining simpler statements, which may be one of these structures, or primitive statements such as assignments or procedure calls." (Dijkstra, 1990) The three basic types of structure identified by Dijkstra were concatenation, selection, and repetition.

LITERATURE REVIEW

Simple sequential code is most easily expressed by concatenation i.e. listing the pieces of code in the correct order. The main related question is how to indicate the boundary between statements. "Some languages just use the end of line but then usually require an explicit continuation symbol for statements too long to fit on a single line. Others languages use an explicit character such as, with some of these treating it as a separator and the rest treating it as the statement terminator." (Birrell, 1995)

To turn a code sequence into a single entity, usually known as a compound statement, some languages use an explicit pair of brackets, such as {} or begin end, as a general form useable with any structure. Some languages have specific forms for each structure, such as if fi (or if end if) and while od (or while end while). Some languages have both general and specific forms, and others have neither. Because structures often end up deeply nested, specific keywords can be much easier to pair up than general pairs.

"The classic selector is the conditional or if statement/expression, and almost all languages have it, usually in two slightly different forms such as if then and if then else." (Agresti, 2000) Some languages place restrictions on the then and else parts, but most modern languages have no such restrictions, allowing nested if statements.

One common pattern of use is:

If ... then...

Else if ... then...

Else if .

More about Three Basic Structures Of Structured Programming

Open Document