• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/20

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

20 Cards in this Set

  • Front
  • Back
What are 3 looping structures used in C++?
for
while
do-while
A while loop continues execution as long as the expressions evaluates to true. What is the while loop does not contain a statement that sets the expression to false?
You will end up with an infinite loop.
Loop control variables are automatically initialized in a loop.
false
A sentinel controlled while loop is a while loop whose termination depends on a special value.
true
In a sentinel-controlled while loop, the body of the loop continues to execute until the EOF symbol is read.
false
The control statements in the for loop include the initial statement, loop condition, and update statement.
true
Assume all variables are properly declared. The following for loop executes 20 times.

for (i = 0; i <= 20; i++)
cout << i;
false
A do...while loop is a post-test loop.
true
Both while and for loops are pre-test loops.
true
The body of a do...while loop may not execute at all.
false
The execution of a break statement in a while loop terminates the loop.
true
A loop that continues to execute endlessly is what type of loop?
infinite
Which loop is guaranteed to execute at least once?
do-while loop
Write a for loop to find the sum of the integers from 1 to 20.
sum = 0;
for (int i = 1; i <= 20; i++)
sum = sum + i;
Write a for loop to print out the word 'hello' 5 times in a row to the screen.
for (int i = 0; i < 5; i++)
cout << "hello" << endl;
What is the least number of times a do-while loop will execute?
one
A for or while loop might never iterate through the loop depending on the conditional statement but a do-while loop will always iterate once before the boolean expression is evaluated
In C++ the words 'for' and 'while' are reserved word.
true
How many times will the word 'hello' be printed?

int i = 1;
while (i <= 20) {
cout << "hello" << endl;
}
infinite
The value for 'i' never changes inside the loop.
Is the following for loop legal?

for (;;)
cout << "hello" << endl;
Yes, but it will be an infinite loop
What is the output of the following for loop that counts backwards?

for (int i = 10; i >= 1; i--)
cout << " " << i;
10 9 8 7 6 5 4 3 2 1