It is used for selecting the proper path out of the

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: , could be expressed by using only the following three simple logic (control) structures: 1. Sequence logic, 2. Selection logic, and 3. Iteration (or looping) logic. It was found that when programs are structured by using only these three logic structures, they can be read from top to bottom and are easier to understand. That is, by conceptualizing the logic of a program in the form of these three logic structures, programmers can avoid writing spaghetti code and produce programs that are easy to understand and maintain. It was found that this also helped in reducing program errors and the time spent in program testing. The use of these three basic control structures resulted in a more scientific approach to solving a programming problem and was later termed as structured programming technique. After realizing the advantages of structured programming technique, many organizations now impose the use of the three basic logic structures in all their programs. It is generally advised as good programming practices to develop program logics and write programs using the three basic logic structures. Hence in the discussion below we will see the pseudocodes for the three basic logic structures (flowcharts of these logic structures have also been shown for those who are rhore comfortable with flowcharts). Sequence Logic Sequence logic is used for performing instructions one after another in sequence. Thus, for sequence logic, pseudocode instructions are written in the order, or sequence, in which they are to be performed. The logic flow of psuedocode is from the top to the bottom. Figure 11.14 shows an example of sequence logic structure. Process l Process 2 (a) Flowchart Process 1 Process 2 (b) Pseudocode Figure 11.14. Flowchart and pseudocode for sequence structure. Selection Logic Selection logic, also known as decision logic, is used for making decisions. It is used for selecting the proper path out of the two or more alternative paths in the program logic. Selection logic is depicted as an IF...THEN...ELSE or an IF...THEN or a CASE structure. The flowcharts of Figures 11.15, 11.16 and 11.17 respective...
View Full Document

This document was uploaded on 04/07/2014.

Ask a homework question - tutors are online