Exam 5: Control Structures II Repetition
Exam 1: An Overview of Computers and Programming Languages50 Questions
Exam 2: Basic Elements of C50 Questions
Exam 3: Inputoutput50 Questions
Exam 4: Control Structures I Selection50 Questions
Exam 5: Control Structures II Repetition50 Questions
Exam 6: User-Defined Functions50 Questions
Exam 7: User-Defined Simple Data Types, Namespaces, and the String Type50 Questions
Exam 8: Arrays and Strings50 Questions
Exam 9: Records Structs50 Questions
Exam 10: Classes and Data Abstraction49 Questions
Exam 11: Inheritance and Composition50 Questions
Exam 12: Pointers, Classes, Virtual Functions, and Abstract Classes50 Questions
Exam 13: Overloading and Templates50 Questions
Exam 14: Exception Handling50 Questions
Exam 15: Recursion50 Questions
Exam 16: Searching, Sorting and the Vector Type50 Questions
Exam 17: Linked Lists50 Questions
Exam 18: Stacks and Queues50 Questions
Select questions type
The following while loop terminates when j > 20.
j = 0;
while (j < 20)
j++;
Free
(True/False)
4.9/5
(35)
Correct Answer:
False
A loop ____________________ is a set of statements that remains true each time the loop body is executed.
Free
(Short Answer)
4.8/5
(41)
Correct Answer:
invariant
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++)
cout << "Hello World";
cout << "!" << endl;
Free
(Multiple Choice)
4.8/5
(30)
Correct Answer:
A
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.
(Short Answer)
5.0/5
(41)
What is the output of the following C++ code? num = 10;
while (num > 10)
num = num - 2;
cout << num << endl;
(Multiple Choice)
4.9/5
(38)
If a(n) ____________________ statement is placed in a do...while structure, the loop-continue test is evaluated immediately after this statement.
(Short Answer)
4.9/5
(41)
The ____________________ statement is typically used for two purposes:
• To exit early from a loop.
• To skip the remainder of a switch structure.
(Short Answer)
4.9/5
(41)
The ____________________ loop has an exit condition but no entry condition.
(Short Answer)
5.0/5
(31)
To generate a random number, you can use the function rand of the header file ____________________.
(Short Answer)
4.8/5
(43)
What is the next Fibonacci number in the following sequence? 1, 1, 2, 3, 5, 8, 13, 21, ...
(Multiple Choice)
4.9/5
(42)
What is the value of x after the following statements execute? int x = 5;
Int y = 30;
Do
X = x * 2;
While (x < y);
(Multiple Choice)
4.9/5
(42)
A loop that continues to execute endlessly is called a(n) ____ loop.
(Multiple Choice)
4.8/5
(38)
Which of the following loops does not have an entry condition?
(Multiple Choice)
4.7/5
(41)
Consider the following code. int limit;
int reps = 0;
cin >> limit;
While (reps < limit)
{
cin >> entry;
triple = entry * 3;
cout << triple;
reps++;
}
cout << endl;
This code is an example of a(n) ____ while loop.
(Multiple Choice)
4.8/5
(36)
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? cin >> sum;
cin >> num;
for (j = 1; j <= 3; j++)
{
cin >> num;
sum = sum + num;
}
cout << sum << endl;
(Multiple Choice)
4.8/5
(37)
The control variable in a flag-controlled while loop is a bool variable.
(True/False)
4.9/5
(35)
Which of the following loops is guaranteed to execute at least once?
(Multiple Choice)
4.9/5
(34)
What executes immediately after a continue statement in a while and do-while loop?
(Multiple Choice)
4.8/5
(43)
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)
{
sum = sum + num;
cin >> num;
}
cout << sum << endl;
(Multiple Choice)
4.8/5
(39)
A software ____________________ is a piece of code written on top of an existing piece of code intended to fix a bug in the original code.
(Short Answer)
4.9/5
(27)
Showing 1 - 20 of 50
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)