Branches Flashcards
What is a branch?
A sequence of statements only executed under certain circumstance.
What creates two branches?
A decision
What symbol is used for decisions?
Diamonds
What is a if-elseif branch?
A branch that contains a decision and branch
What is it called when a branch itself contains a decision and branches?
If-elseif branches
What is the difference between if-elseif branches and multiple-if-branches?
In if-elseif branches each only one branch can execute
With multiple-if-branches each decision is independent, thus more than one branch can execute
What is the difference between a branch and a decision?
A branch is a sequence of statements only executed under a certain condition
A decision creates two branches (decisions are diamonds), branches flow from decisions
Which operator check whether two operands’ values are different?
!=
What does a relational operator do?
Checks how one operand’s value relates to another.
Like being greater than, or less than.
Logical operators include?
And, or, not
Describe the logical operator (a) and (b).
Logical AND: true when both operands are true
Describe the logical operator (a) or (b).
Logical OR: true when at least one of the two operands is true
Describe the logical operator not(a).
Logical NOT: true when the one operand is false, and vice-versa
If there are no gaps in a series of ranges, is the range implicit or explicit?
Implicit
Floating point numbers should not be compared using which operator?
==
A leap year must be divisible by?
4
If the year is a century year it must be evenly divisible by?
400
What does the variable max represent?
The max value seen so far.
What is a while loop?
A loop that repeatedly executes the loop body while the loop’s expression evaluates to true.
What is a for loop?
A loop consisting of a loop variable initialization, a loop expression, and a loop variable update that typically describes iterating for a specific number of times.
Finish the following - number of iterations is computable…….
Before the loop, like iterating N times.
For
Finish the following - Number of iterations is not…….
Easily computable before the loop, like iterating until the input is ‘q’.
While