?

Quiz #1 – Review of C++ Basics

Started: Nov 26 at 11:23pm

Quiz Instructions

Please review the Review Questions For Chapters 1-8 file before you take this quiz for any topics to review before taking the quiz. The quiz has 50 questions (each worth 2 points). The test is open for 90 minutes and you can take the quiz up to two times. The highest grade will be kept. Good Luck!

Note: this is a timed quiz. You may check the remaining time you have at any point while taking the quiz by pressing the keyboard combination SHIFT, ALT, and T… Again: SHIFT, ALT, and T…
?

Question 12?pts

The _____ causes the contents of another file to be inserted into a program.

?
?
?

Question 22?pts

_____________ represent storage locations in the computer’s memory.

?
?
?

Question 32?pts

A A ?? A character literal is enclosed in ________ quotation marks, whereas a string literal is enclosed in ________ quotation marks.

?
?
?

Question 42?pts

What is the modulus operator?

?
?
?

Question 52?pts

In thIn a C++ instruction,

 

cookies = number % children;

 

 

given the following declaration statement:

 

int number = 38, children = 4, cookies;

 

what is the value of cookies after the execution of the statement?

?
?
?

Question 62?pts

HowHow would you consolidate the following declaration statements into one statement?

 

int x = 7;

int y = 16;

int z = 28;

?
?
?

Question 72?pts

 

A va ? ? A variable called “average” should be declared as an integer data type because it will probably hold data that contains decimal places.

 

?
?
?

Question 82?pts

Floating point constants are normally stored in memory as doubles.

?
?
?

Question 92?pts

The ______ operator always follows the?cin?object, and the ______ operator follows the?cout?object.

?
?
?

Question 102?pts

Wha ? ? ?? What?is the value stored at?x, given the statements:

int x;

x = 3 / static_cast<int>(4.5 + 6.4);

?
?
?

Question 112?pts

The function,?pow(x, 5.0), requires this header file.

?
?
?

Question 122?pts

? ? ? ? ? ? ? ? When?the final value of an expression is assigned to a variable, it will be converted to:

?
?
?

Question 132?pts

?? To use the rand() function, you must include the following header file in your program.

?
?
?

Question 142?pts

This stream manipulator forces?cout?to print the digits in fixed-point notation.

?
?
?

Question 152?pts

15.?After execution of the following code, what will be the value of input_value if the value 0 is entered at the keyboard at run time?

cin >> input_value;
if (input_value > 5)
input_value = input_value + 5;
else if (input_value > 2)
input_value = input_value + 10;
else
input_value = input_value + 15;

?
?
?

Question 162?pts

What will be the output of the following code segment after the user enters 0 at the keyboard?

int x = -1;
cout << “Enter a 0 or a 1 from the keyboard: “;
cin >> x;
if (x)
cout << “true” << endl;
else
cout << “false” << endl;

?
?
?

Question 172?pts

What is assigned to the variable a given the statement below with the following assumptions: x = 10, y = 7, and z, a, and b are all int variables.

a = x >= y;

?
?
?

Question 182?pts

If you place a semicolon after the statement if (x < y)

?
?
?

Question 192?pts

What will following segment of code output?

int x = 5;
if (x = 2)
cout << “This is true!” << endl;
else
cout << “This is false!” << endl;
cout << “This is all folks!” << endl;

?
?
?

Question 202?pts

What will the following segment of code output? You can assume the user enters a grade of 90 from the keyboard.

cout << “Enter a test score: “;
cin >> test_score;
if (test_score < 60);
cout << “You failed the test!” << endl;
if (test_score > 60)
cout << “You passed the test!” << endl;
else
cout << “You need to study for the next test!”;

?
?
?

Question 212?pts

This operator represents the logical AND.

?
?
?

Question 222?pts

Input values should always be checked for

?
?
?

Question 232?pts

Without this statement appearing in a switch construct, the program “falls through” all of the statements below the one with the matching case expression.

?
?
?

Question 242?pts

What will the following segment of code output if 11 is entered at the keyboard?

int number;
cin >> number;
if (number > 0)
cout << “C++”;
else
cout << “Soccer”;
cout << ” is “;
cout << “fun” << endl;

?
?
?

Question 252?pts

What will the following program segment display?

int funny = 7, serious = 15;
funny = serious % 2;
if (funny != 1)
{
funny = 0;
serious = 0;
}
else if (funny == 2)
{
funny = 10;
serious = 10;
}
else
{
funny = 1;
serious = 1;
}
cout << funny << ” ” << serious << endl;

?
?
?

Question 262?pts

What will the following program display?

#include <iostream>
using namespace std;
int main()
{
int a = 0, b = 2, x = 4, y = 0;
cout << (a == b) << ” “;
cout << (a != b) << ” “;
cout << (b <=x) << ” “;
cout << (y > a) << endl;
return 0;
}

?
?
?

Question 272?pts

What is the output of the following code segment?

n = 1;
while (n <= 5)
cout << n << ‘ ‘;
n++;

?
?
?

Question 282?pts

The while loop has two important parts: an expression that is tested for a true or false value, and:

?
?
?

Question 292?pts

The statements in the body of a while loop may never be executed, whereas the statements in the body of a do-while loop will be executed:

?
?
?

Question 302?pts

Look at the following statement.

while (x++ < 10)

Which operator is used first?

?
?
?
?

Question 312?pts

What is the output of the following code segment?

n = 1;
for ( ; n <= 5; )
cout << n << ‘ ‘;
n++;

?
?
?

Question 322?pts

int number = 6;
++number;
cout << number << endl;

?
?
?

Question 332?pts

for (int i = 20; i > 0; i–)
cout << “Hello!” << endl;

 

?
?
?

Question 342?pts

The value in this type of local variable persists between function calls.

?
?
?

Question 352?pts

_________ functions may have the same name, as long as their parameter lists are different

?
?
?

Question 362?pts

void calc (int a, int& b)
{
int c;

c = a + 2;
a = a * 3;
b = c + a;
}

What is the output of the following code fragment that invokes calc?
(All variables are of type int)

x = 1;
y = 2;
z = 3;
calc(x, y);
cout << x << ” ” << y << ” ” << z << endl;

?
?
?

Question 372?pts

Which of the following statements about global variables is true?

?
?
?

Question 382?pts

What is the output of the following program?

#include <iostream>
using namespace std;

void showDub(int);

int main()
{
int x = 2;

showDub(x);
cout << x << endl;
return 0;
}

void showDub(int num)
{
cout << (num * 2) << endl;

 

The answers are vertically displayed below – Canvas will not allow answers on more than one line.
}

?
?
?

Question 392?pts

What is the output of the following program?

#include <iostream>
using namespace std;

void doSomething(int&);

int main()
{
int x = 2;

cout << x << endl;
doSomething(x);
cout << x << endl;
return 0;
}

void doSomething(int& num)
{
num = 0;
cout << num << endl;
}

The answers below are vertically displayed, but Canvas can not handle this display.

?
?
?

Question 402?pts

True/False: A static variable that is defined within a function is initialized only once, the first time the function is called.

 

 

?
?
?

Question 412?pts

Which of the following is a valid C++ array definition?

?
?
?

Question 422?pts

By using the same ________ you can build relationships between data stored in two or more arrays.

?
?
?

Question 432?pts

Given the following declaration, where is 77 stored in the scores array?

int scores[]={83, 62, 77, 97};

?
?
?

Question 442?pts

Which statement correctly defines a vector object for holding integers?

?
?
?

Question 452?pts

What does the following statement do?

vector<int> v(10, 2);

?
?
?

Question 462?pts

A ________ algorithm is a method of locating a specific item of information in a larger collection of data.

?
?
?

Question 472?pts

The _________ sort usually performs fewer exchanges than the ________ sort.

?
?
?

Question 482?pts

Using a linear search to find a value that is stored in the last element of an array of 20,000 elements, ____________ element(s) must be compared.

?
?
?

Question 492?pts

True/False: Before you can perform a selection sort, the data must be stored in ascending order.

 

?
?
?

Question 502?pts

True/False: The number of comparisons made by a binary search is expressed in powers of two.

 

?
?
?
?
?
Not saved?
  • Time Running:?

    Attempt due: Dec 14 at 12:59pm
    ?
    1 Hour, 29 Minutes, 45 Seconds
    ?
    ?