Exam 6: Flow of Control, Part 2: Looping

arrow
  • Select Tags
search iconSearch Question
flashcardsStudy Flashcards
  • Select Tags

Using the for loop header for( int i = 0; i < 5; i++ ), the variable i will still be in scope after we exit the for loop.

(True/False)
4.7/5
(38)

Describe the conditions under which you would want to use a sentinel value.

(Essay)
4.8/5
(40)

A logic error is likely to happen if we set the sentinel value -1 in an addition calculator.

(True/False)
4.8/5
(43)

A special value that the user enters to signal the end of the input is called a(n) __________ value.

(Multiple Choice)
4.8/5
(38)

When a loop condition is grade >= 90, what values would you use to test your loop?

(Multiple Choice)
4.9/5
(32)

A loop condition may be simplified by applying __________ laws.

(Short Answer)
4.7/5
(36)

A while loop can be nested inside a for loop and vice versa.

(True/False)
4.7/5
(44)

When you use a while loop to compute the sum of several values, you should initialize the variables holding the sum to:

(Multiple Choice)
4.8/5
(31)

You have a for loop nested in a while loop in order to find prime numbers. The proper way is to set the flag to false before starting the for loop that checks for factors. Inside the for loop, set the flag to true when a factor is found. After the for loop terminates, check the value of the flag. If it is still false, no factors were found and the number is prime.

(True/False)
4.9/5
(38)

When you use a sentinel value for the condition of a loop that processes user inputs, what case should you not forget to test?

(Multiple Choice)
4.9/5
(40)

When reading data from a user, the first time we read is called the __________.

(Short Answer)
4.9/5
(40)

In a for loop, a loop control variable is usually, but not always, for counting.

(True/False)
4.9/5
(37)

How many times will a loop with the for loop header for ( i = 5; i < 15; i++ ) execute?

(Multiple Choice)
4.9/5
(35)

for loops can be nested.

(True/False)
4.9/5
(39)

Which of the following questions should you ask to verify a clean program?

(Multiple Choice)
4.8/5
(38)

The loop condition can be a complex condition involving several logical, equality, and relational operators.

(True/False)
4.9/5
(39)

To get a floating-point average, type cast one of the variables (either total or count) to a double or a float to force the division to be performed as floating-point. double average = (double) ( total ) / count;

(True/False)
4.9/5
(34)

You should always put a semicolon after the closing parenthesis in a for loop header.

(True/False)
4.7/5
(47)

When we use a while loop, we always know in advance how many times the loop body will be executed.

(True/False)
4.8/5
(33)

Using an if statement to validate input will find all errors without reprompting.

(True/False)
4.7/5
(37)
Showing 21 - 40 of 67
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)