Filters
Question type

Study Flashcards

What is the output of the following C++ code? What is the output of the following C++ code?   A)  0 B)  6 C)  8 D)  10


A) 0
B) 6
C) 8
D) 10

Correct Answer

verifed

verified

A semicolon at the end of the for statement (just before the body of the loop) is a(n) ____________________ error.

Correct Answer

verifed

verified

The ____ statement can be used to eliminate the use of certain (flag) variables.


A) while
B) switch
C) break
D) if

Correct Answer

verifed

verified

In the case of the sentinel-controlled while loop, the first item is read before the while loop is entered.

Correct Answer

verifed

verified

What is the initial statement in the following for loop? (Assume that all variables are properly declared.) What is the initial statement in the following for loop? (Assume that all variables are properly declared.)    A)  i = 1; B)  i < 20; C)  i++; D)  cout <<  Hello World ;


A) i = 1;
B) i < 20;
C) i++;
D) cout << "Hello World";

Correct Answer

verifed

verified

A

When a continue statement is executed in a ____, the update statement always executes.


A) while loop
B) for loop
C) switch structure
D) do...while loop

Correct Answer

verifed

verified

Suppose sum, num, and j are int variables, and the input is 4 7 12 9 -1. What is the output of the following code? Suppose sum, num, and j are int variables, and the input is 4 7 12 9 -1. What is the output of the following code?   A)  24 B)  25 C)  41 D)  42


A) 24
B) 25
C) 41
D) 42

Correct Answer

verifed

verified

A

Assume that all variables are properly declared. The following for loop executes 20 times. Assume that all variables are properly declared. The following for loop executes 20 times.

Correct Answer

verifed

verified

False

Consider the following code. This code is an example of a(n) ____ while loop. Consider the following code. This code is an example of a(n)  ____ while loop.   A)  flag-controlled B)  counter-controlled C)  EOF-controlled D)  sentinel-controlled


A) flag-controlled
B) counter-controlled
C) EOF-controlled
D) sentinel-controlled

Correct Answer

verifed

verified

What is the output of the following C++ code? What is the output of the following C++ code?   A)  10 B)  10 10 C)  10 11 D)  11 11


A) 10
B) 10 10
C) 10 11
D) 11 11

Correct Answer

verifed

verified

In a while and for loop, the loop condition is evaluated before executing the body of the loop. Therefore, while and for loops are called ____________________ loops.

Correct Answer

verifed

verified

____ loops are called posttest loops.


A) break
B) for
C) while
D) do...while

Correct Answer

verifed

verified

A loop that continues to execute endlessly is called a(n) ____ loop.


A) end
B) unhinged
C) infinite
D) definite

Correct Answer

verifed

verified

Suppose sum and num are int variables, and the input is 18 25 61 6 -1. What is the output of the following code? Suppose sum and num are int variables, and the input is 18 25 61 6 -1. What is the output of the following code?   A)  92 B)  109 C)  110 D)  119


A) 92
B) 109
C) 110
D) 119

Correct Answer

verifed

verified

The control statements in the for loop include the initial statement, loop condition, and update statement.

Correct Answer

verifed

verified

In ____ structures, the computer repeats particular statements a certain number of times depending on some condition(s) .


A) looping
B) branching
C) selection
D) sequence

Correct Answer

verifed

verified

Which of the following statements generates a random number between 0 and 50?


A) srand(time(0) ) ;
Num = rand() % 50;
B) srand(time(10) ) ;
Num = rand() /50;
C) srand(time(0) ) ;
Num = rand() 50;
D) srand(time(10) ) ;
Num = rand() % 50;

Correct Answer

verifed

verified

A(n) ____-controlled while loop uses a bool variable to control the loop.


A) counter
B) sentinel
C) flag
D) EOF

Correct Answer

verifed

verified

Which executes first in a do...while loop?


A) the statement
B) loop condition
C) the expression
D) update statement

Correct Answer

verifed

verified

In a counter-controlled while loop, the loop control variable must be initialized before the loop.

Correct Answer

verifed

verified

Showing 1 - 20 of 40

Related Exams

Show Answer