This preview shows page 1. Sign up to view the full content.
Unformatted text preview: ode is not equal to Z, that is, as long
as the trailer record is not fond. In this example, a series of decisions followed by an
instruction to read next student's record are included within the loop. The first statement
within the DO.. .WHILE loop asks, "Is the Sexcode equal to F?" If the answer is yes, Pergentage is calculated and again the third statement within the loop asks, "Is
Percentage equal to or greater than 45?" If it is, then "Is Percentage less than 60?" This is
a series of three IF...THEN decision structures. Each one ends with an ENDIF vertically
aligned below the appropriate IF.
The two instructions - "Write output data" and "Add 1 to Count" are performed only if all
the three conditions (that of Sexcode being F, Percentage being equal to or more than 45,
and Percentage being less than 60) are found to be true (answered yes). If any of the three
conditions is not true, the logic path goes to the statement that reads the next student's
record. After the last student's record is processed, the trailer record for which the value
of Sexcode is Z is encountered. This will cause the DO...WHILE loop to stop, because
the condition (Sexcode not equal to Z) is no longer true. When the DO.. .WHILE
condition is no longer true, the next logical step will be the instruction following the
ENDDO. At this stage, the value of Count will be printed (Write Count) and finally the
program execution will stop (Stop).
Set Count to zero
Read first student record
DO WHILE Sexcode is not equal to Z
IF Sexcode = F THEN
IF Percentage = > 45 THEN
IF Percentage < 60 THEN
Write output data
Add 1 to Count
Read next student record
One important feature of pseudocode as a programming tool is the use of indentation.
Each statement within the DO...WHILE loop is indented, to show that it is part of the
loop. Similarly, the statements within each IF...THEN structure is indented properly to
clearly specify the statements, which are part of each structure. The use of...
View Full Document
- Spring '14