This preview shows page 1. Sign up to view the full content.
Unformatted text preview: ly illustrate the logic of these
structures. Their corresponding pseudocodes are also given in these figures.
The IF... THEN... ELSE construct says that if the condition is true, then do Process 1,
else (if the condition is not true) do Process 2. Thus, in this case either Process 1 or
Process 2 will be executed depending on whether the specified condition is true or false.
However, if we do not want to choose between the two processes and if we simply want
to decide if a process is to be performed or not, then the IF...THEN structure is used. The
IF... THEN structure says that if the condition is true, then do Process 1 and if it is not
true then skip over Process 1.
The CASE structure is a multiple-way selection logic structure that allows to choose
between more than two control paths in a program logic. It allows the selection of one of
any number of statements or statement groups. It is, therefore, a generalization of the
one-way (IF...THEN) and two-way (IF...THEN...ELSE) selection logic structures. In fact,
one-way and two-way selection logic structures can be built with a multiple-way
selection logic structure. The CASE statement says that if the value of Type is equal to
Type-1 then execute Process 1, if it is equal to Type-2 then execute Process 2, if it is
equal to Type-3 then execute Process 3, and so on.
THEN Process 1
ELSE Process 2
In all these structures, Process 1, Process 2, Process 3, etc. can actually be one or more
processes. They are not limited to a single process. ENDIF is used to indicate the end of
the IF,... THEN and IF... THEN.. .ELSE decision structures and ENDCASE is used to
indicate the end of the CASE structure.
Iteration (or Looping) Logic
Iteration logic is used to produce loops in program logic when one or more instructions
may be executed several times depending on some condition. It uses two structures called
the DO...WHILE and the REPEAT...UNTIL. They are illustrated by flowcharts in Figure 11.18 and Figure 11.19 respectively. Their corresponding pseudocodes are also g...
View Full Document
- Spring '14