Exam 5: Control Structures II (Repetition)
Exam 1: An Overview of Computers and Programming Languages50 Questions
Exam 2: Basic Elements of C++50 Questions
Exam 3: Input/Output50 Questions
Exam 4: Control Structures I (Selection)50 Questions
Exam 5: Control Structures II (Repetition)50 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 (structs)50 Questions
Exam 10: Classes and Data Abstraction50 Questions
Exam 11: Inheritance and Composition50 Questions
Exam 12: Pointers, Classes, Virtual Functions, Abstract Classes, and Lists50 Questions
Exam 13: Overloading and Templates50 Questions
Exam 14: Exception Handling50 Questions
Exam 15: Recursion50 Questions
Exam 16: Linked Lists50 Questions
Exam 17: Stacks and Queues50 Questions
Exam 18: Searching and Sorting Algorithms50 Questions
Exam 19: Binary Trees50 Questions
Exam 20: Graphs50 Questions
Exam 21: Standard Template Library (STL)50 Questions
Select questions type
To generate a random number,you can use the function rand of the header file ____________________.
Free
(Short Answer)
4.8/5
(44)
Correct Answer:
cstdlib
Which of the following statements generates a random number between 0 and 50?
Free
(Multiple Choice)
4.9/5
(38)
Correct Answer:
A
Assume that all variables are properly declared.The following for loop executes 20 times.
for (i = 0; i <= 20; i++)
cout << i;
Free
(True/False)
4.8/5
(42)
Correct Answer:
False
What is the output of the following C++ code? num = 10;
while (num > 10)
num = num - 2;
cout << num << endl;
(Multiple Choice)
4.7/5
(43)
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.9/5
(38)
The control statements in the for loop include the initial statement,loop condition,and update statement.
(True/False)
4.9/5
(30)
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;
(Multiple Choice)
4.8/5
(39)
Putting one control structure statement inside another is called ____________________.
(Short Answer)
4.8/5
(35)
In ____ structures,the computer repeats particular statements a certain number of times depending on some condition(s).
(Multiple Choice)
4.9/5
(39)
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)
4.8/5
(29)
A loop that continues to execute endlessly is called a(n)____ loop.
(Multiple Choice)
4.8/5
(34)
What executes immediately after a continue statement in a while and do-while loop?
(Multiple Choice)
4.9/5
(34)
A semicolon at the end of the for statement (just before the body of the loop)is a(n)____________________ error.
(Short Answer)
4.8/5
(36)
A do...while loop is a(n)____________________ loop,since the loop condition is evaluated after executing the body of the loop.
(Short Answer)
4.8/5
(32)
The for loop body executes indefinitely if the loop condition is always ____________________.
(True/False)
4.9/5
(37)
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.7/5
(32)
What is the output of the following C++ code? count = 1;
num = 25;
while (count < 25)
{
num = num - 1;
count++;
}
cout << count << " " << num << endl;
(Multiple Choice)
4.8/5
(40)
Showing 1 - 20 of 50
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)