Flowcharts: Are equality tests always listed in decision symbols?

Questions ArchiveFlowcharts: Are equality tests always listed in decision symbols?
Garret Quinton asked 2 years ago

Based on the book’s explanation (included below for reference) I assume that an equality test is always found in a diamond/decision symbol, and that an assignment is always found in a rectangle/process symbol. Would that be correct? The book is unclear on this point.
9.6Assignments versus Equalities
In an assignment, the result of the calculation on the right side of an equals sign is assigned to a variable on the left of the equals sign. For example, consider the assignment “Pay = Hours * Rate.” In this assignment, Hours is multiplied by Rate, and the result of this calculation is assigned to the Pay variable on the left of the equals sign. Assignments always go from right to left. That is, once the operation on the right side of the equals sign is completed, then the result is assigned to the variable on the left of the equals sign.
A test of equality, on the other hand, is a logical test that evaluates whether two values are equivalent. Like all other decision diamonds, tests of equality return either true or false. With a test of equality, if what is on the left and right side of the equal symbol are equal, the test of equality returns true; otherwise, it returns false. Tests of equality are part of conditional logic. For example: If Today = “Friday,” Then Balance = Balance – 50. In this case, we check to see if the value of the Today variable is equal to “Friday.” Then, if it is, we take 50 away from our Balance and assign that new value to our Balance variable. The left side of this statement (the “if” portion) is a test of equality, while the right side (the “then” portion) is a value assignment.

2 Answers
Justis answered 2 years ago

Yes you are correct, equality tests are gonna happen in decision boxes and assignments are gonna happen in other boxes. In actual programming there isn’t really a way to define if it’s a decision or a process so in most languages you use = for assignment and === or == or != for comparison

Cory Anderson answered 2 years ago

Equality tests (i.e. is X > 5?) are always in decision (diamond) symbols. This is because there must be 2 outputs (yes and no) which is not possible in a rectangular shape which only allows 1 output

Your Answer

4 + 14 =