4.1 while Loops
Enduring Understanding
Programmers incorporate iteration and selection into code as a way of providing instructions for the computer to process each of the many possible input values.
Learning Objective
Represent iterative processes using a while loop.
Essential Knowledge
Iteration statements change the flow of control by repeating a set of statements zero or more times until a condition is met.
In loops, the Boolean expression is evaluated before each iteration of the loop body, including the first. When the expression evaluates to true, the loop body is executed. This continues until the expression evaluates to false, whereupon the iteration ceases.
A loop is an infinite loop when the Boolean expression always evaluates to true.
If the Boolean expression evaluates to false initially, the loop body is not executed at all.
Executing a return statement inside an iteration statement will halt the loop and exit the method or constructor.
Learning Objective
For algorithms in the context of a particular specification that does not require the use of traversals:
Identify standard algorithms.
Modify standard algorithms.
Develop an algorithm.
Essential Knowledge
There are standard algorithms to:
Identify if an integer is or is not evenly divisible by another integer
Identify the individual digits in an integer
Determine the frequency with which a specific criterion is met
There are standard algorithms to:
Determine a minimum or maximum value
Compute a sum, average, or mode
Last updated
Was this helpful?