Chapter 51
Chapter 51
Decisions
CHAPTER 5
2- An expression using relational operators (<, <=, >, >=, =, and < >).
The programmer can set up the conditions for a decision through the use of
operands and various operators.
These conditions can be used alone or linked with other conditions for use in
the instruction.
The programmer derives the information needed to set up the condition(s) for a
decision from the problem itself during problem analysis
Multiple Condition
In these decisions you will use logical operators to connect the conditions.
There is no Else part of the instructions; the False branch always goes to the
next decision, and the True branch goes to the next decision after the
instructions for the True branch have been processed.
With decisions following Straight-through logic, all conditions are tested. To test
a condition means to process a condition to get a True or False resultant.
You must use it to solve certain problems, those that require two or more
unrelated decisions, and those in which all decisions must be processed,
Example: in data validation (checking data to make sure it is correct)
When you use positive logic, you are telling the computer to follow a set of
instructions and continue processing if the condition is True; if the condition is
not True, then the computer processes another decision.
When you use this logic, no more decisions are processed once the resultant of
a condition is True.
When you use negative logic you are telling the computer to process another
decision when the resultant of the condition is True; if the resultant is False,
then the computer processes a consequent set of instructions and continues
processing the module.
In a decision, there must always be instructions for a True section, but not
always for a False section. If there are no instructions for the True section of a
decision instruction, then it is better to convert the logic type.
Note: The total number of possible combinations of True or False for the
conditions is 2^ #conditions