Chapter 5

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

count-controlled loop

_____-_________ ____ is a loop that repeats a specific number of times. it must possess three elements: 1) IT must initialize a counter variable to a starting value. 2) It must test the counter variable by comparing it to a final value. When the counter variable reaches its final value, the loop terminates. 3) It must update the counter variable during each iteration. This is usually done by incrementing the variable.

iteration

each execution of a loop

conditional loop

executes as long as a particular condition exists.

body

This contains or more C++ statements. The condition expression is tested, and if it is true, each statement in the body of the loop is executed. Then, the condition is tested again. If it is still true, each statement is executed again. This cycle repeats until the condition is false. As with an (if) statement, each statement in the _____ of the loop is to be conditionally executed ends with a semicolon.

running total

a _______ _____ is a sum of numbers that accumulates with each iteration of a loop. The variable used to keep the _______ ____ is called an accumulator.

sentinel

a _______ is a special value that marks the end of a list of values

counter

a _______ is a variable that is regularly incrememted or decremented each time a loop iterates.

nested loop

a loop inside another loop

loop control variable

a variable that controls the number of time a loop iterates is referred to as a ____ _______ _______.

priming read

provides the first value for the loop to test.

pretest

the (while) loop is known as a ______ loop, which means it tests its expression before each iteration.

do-while loop

the __-_____ ____ is a post test loop. it looks similar to a while loop turned upside down. A good choice for repeating a menu.

end of file

the ___ __ _____ function of the fstream class signals the end of file and is used to terminate a loop used to read data from a file.

for loop

the ____ ____ is a pretest loop that combines the initialization, testing, and updating of a loop control varialbe in a single loop header. A type of loop specifically for count-controlled loops.

break

the _____ statement causes a loop to terminate early.

while

the ______ loop has two important parts: 1) an expression that is tested for a true or false value, and 2) a statement or block that is repeated as long as the expression is true.

condition

the _______ of a (while) loop is expressed by any expression that can be evaluated as true or false.

continue

the _______ statement causes a loop to stop its current iteration and begin the next one.

loop header

the first line of a loop, sometimes called the ____ _____, consists of the key word (while) follwed by a (condition) to be tested enclosed in parentheses.

input validation

the process of inspecting data given to a program by the user an determining if it is valid. The while loop is especially useful for _____ _________.

increment

to _________ a value means to increase it, and to decrement a value means to decrease it. Three different ways to write: ( num = num+1, num += 1, num++ )


Ensembles d'études connexes

apush period 5 test review (wip)

View Set

Quantitative methods in psychology exam 1, Exam 1 All, Kilianski Exam 1 Quantitative Methods conceptual, Quantitative Methods Exam 1, Quantitative Methods in Psychology: Exam 1

View Set

MD 1201-1400 ចម្លើយពេញ

View Set

Microeconomics Exam 01 Study Guide

View Set

Chapter 2 - Prioritization, Delegation, and Assignment

View Set