Three Basic Structures of Structured Programming

962 Words4 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…show more content…
"Almost all languages provide some sort of determinate loop, usually known as a for-loop or do-loop. The basic form is a loop that e.g. counts from 1 to 10, and some languages provide little more than this: e.g.: for I = 1 to 10 do." (Fream, 1992) Because of this some languages do not bother to test the condition until the end of each repetition. Various enhancements exist: variables or expressions for start and stop values, increments other than 1, decrements, automatic declaration of the counter variable, scalar types other than integer. Some languages guarantee a particular value of the counter outside the loop or permit it to be modified inside the loop, whereas others do not, so as to allow for optimizations and because modifying the counter does not lead to good quality code. We can transform the while statement into a loop containing a list of guarded statements, that repeats until none of the guards is valid e.g.: While I < j do j -= I J < I do I -= j End This example terminates when I equals j. CONCLUSION Coders should break larger pieces of code into shorter subroutines (functions, procedures. methods, blocks, or otherwise) that are small enough to be understood easily. In general, programs should

More about Three Basic Structures of Structured Programming

Open Document