Conditional statements allow us to choose to run a portion of code, or not. It is dependent upon what they condition is, and if it is met.
Conditions need resolved down to a boolean answer. That is one that can be described as a yes/no, or true/false, style of answer. Therefore “Is the shirt blue?” is good, as if “blue” is defined, we can determine if the shirt color is the color blue. On the other hand, “What color is the shirt?” is not a good decision question as you don’t know how to handle all of the possible answers that might be given.
Decisions in Flowcharts
In a Flowchart, decisions are made via a diamond symbol. The decision question is written inside of the diamond shape.
Unlike most flowchart symbols, it has one flowline coming in, and two leaving. One for if the decision is true, and one for if the decision is false. We will go further and label these flowlines to make sure it is as clear as possible for all people involved.
You must have two flowlines, yes and no/true and false.
Typically, the yes flowline comes out of the (right) side, but this isn’t always the case. The no flowline typically comes out of the bottom, but once again, not always. It’s what ever makes the flowchart easier to read.
Decisions With Different Results
Since you can have a flowline for both the true and the false result, that means you can have a series of steps for both of them. This is known as an if-else in programming languages, and is really easy to create in a flowchart software like Lucid Chart.
Intro to Conditional Statements was originally found on Access 2 Learn
4 Comments
Comments are closed.