Chapter 5 Flashcards
Inside the brackets of the loop is a _____ expression. This means the loop continues until the Boolean expression is ______
Boolean
False
What is the syntax for a while loop
While (loop-continuation-condition)
{
Statement(s)
}
Can you use floating point values for equality checking in a loop expression?
No because floating point numbers are an approximation
What is the function of eof()?
When reading text from a file it will terminate a loop when the end of the file is reached?
Eof returns _____ when the end of the file is reached. Because of this it is to have the syntax written like….
True
While (!input.eof())
A do while loop is the same as a while loop except that…..
It executes the loop first and then checks the loop condition
What is the syntax of a do while loop?
do
{
Statement(s)
} while (loop-continuation-condition)
what is the syntax of a for loop
for (intial-action; loop-continuation-condition; action-after-each-iteration)
{
statement(s)
}
a for loop generally uses a variable to control how many times the loop body is executed and when the loop terminates, this is called a _____ _____
control variable
the initial-action in a for loop often _____ the control variable.
intializes
the action-after-each-iteration in a for loop usually ____ or ____ the control variable
increments
decrements
the loop-continuation-condition in a for loop tests wether the control varibale has….
reached termination variable
for loops and while loops are called ____ loops
pretest
do-while are called ____ loops
postest
in general, a ____ loop is if the number of repetitions is known in advance
for