Filters
Question type

Study Flashcards

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

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

What is the output of the following C++ code? num = 10; while (num > 10) \quad num = num - 2; cout << num << endl;


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

Correct Answer

verifed

verified

A do...while loop is a(n)____________________ loop,since the loop condition is evaluated after executing the body of the loop.

Correct Answer

verifed

verified

Putting one control structure statement inside another is called ____________________.

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? sum = 0; Cin >> num; While (num != -1) { \quad Sum = sum + num; \quad Cin >> num; } Cout << sum << endl;


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

Correct Answer

verifed

verified

What executes immediately after a continue statement in a while and do-while loop?


A) loop-continue test
B) update statement
C) loop condition
D) the body of the loop

Correct Answer

verifed

verified

To generate a random number,you can use the function rand of the header file ____________________.

Correct Answer

verifed

verified

cstdlib

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

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

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


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

Correct Answer

verifed

verified

Assume that all variables are properly declared.The following for loop executes 20 times. for (i = 0; i <= 20; i++) \quad cout << i;

Correct Answer

verifed

verified

False

What is the output of the following C++ code? count = 1; num = 25; while (count < 25) { \quad num = num - 1; \quad count++; } cout << count << " " << num << endl;


A) 24 0
B) 24 1
C) 25 0
D) 25 1

Correct Answer

verifed

verified

Consider the following code. int limit; Int reps = 0; Cin >> limit; While (reps < limit) { \quad Cin >> entry; \quad Triple = entry * 3; \quad Cout << triple; \quad Reps++; } Cout << endl; This code is an example of a(n) ____ while loop.


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

Correct Answer

verifed

verified

Which of the following is a repetition structure in C++?


A) if
B) switch
C) while...do
D) do...while

Correct Answer

verifed

verified

The for loop body executes indefinitely if the loop condition is always ____________________.

Correct Answer

verifed

verified

What is the initial statement in the following for loop? (Assume that all variables are properly declared.) int i; For (i = 1; i < 20; i++) \quad Cout << "Hello World"; \quad Cout << "!" << endl;


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

Correct Answer

verifed

verified

____ loops are called posttest loops.


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

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

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

Showing 1 - 20 of 50

Related Exams

Show Answer