Several categories of computers exist, such as…
|
Mainframe, midsize, and micro
|
The basic commands that a computer performs are _____, and performance of arithmetic and logical operations.
|
input, output, storage
|
Main memory is called…
|
random access memory
|
The ____ is the brain of the computer and the single most expensive piece of hardware in your personal computer.
|
CPU
|
Main memory is an ordered sequence of items, called…
|
memory cells
|
The devices that the computer uses to display results are called ____ devices
|
output
|
The devices that feed data and programs into computers are called _____ devices
|
input
|
When the power is switched off, everything in ____ is lost
|
main memory
|
_____ programs perform a specific task.
|
Application
|
The ____ monitors the overall activity of the computer and provides services.
|
Operating system
|
____ represent information with a sequence of 0s and 1s
|
Digital signals
|
A sequence of eight bits is called a…
|
Byte
|
the digit 0 or 1 is called a binary digit, or…
|
Bit
|
The term GB refers to…
|
Gigabyte
|
___ consists of 65,536 characters
|
Unicode
|
A program called a ___ translates instructions written in high level languages into machine code
|
compiler
|
Consider the following C++ program.
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World "
return 0;
}
In the cout statement, the missing semicolon in the code above will be caught by the ____.
a. compiler c. assembler
b. editor d. control unit
|
Compiler
|
A program called a(n) ____ combines the object program with the programs from libraries.
a. assembler c. linker
b. decoder d. compiler
|
Linker
|
A program that loads an executable program into main memory is called a(n) ____.
a. compiler c. linker
b. loader d. assembler
|
Loader
|
A step-by-step problem-solving process in which a solution is arrived at in a finite amount of time is
called a(n) ____.
a. algorithm c. analysis
b. linker d. design
|
Algorithm
|
To develop a program to solve a problem, you start by ____.
a. analyzing the problem
b. implementing the solution in C++
c. designing the algorithm
d. entering the solution into a computer system
|
Analyzing the problem
|
Dividing a problem into smaller subproblems is called ____ design.
a. OOD c. structured
b. top-down refinement d. analog
|
structured
|
A(n) ____ consists of data and the operations on those data.
a. disk c. interpreter
b. compiler d. object
|
object
|
The programming language C++ evolved from ____.
|
C
|
The programming language C++ was designed by Bjarne Stroustrup at Bell Laboratories in the early
____.
a. 1960s c. 1980s
b. 1970s d. 1990s
|
1980s
|
The ____ rules of a programming language tell you which statements are legal, or accepted by the
programming language.
a. semantic c. syntax
b. logical d. grammatical
|
Syntax
|
Which of the following is a reserved word in C++?
a. char c. CHAR
b. Char d. character
|
char
|
Which of the following is a legal identifier?
a. program! c. 1program
b. program_1 d. program
|
program_1
|
____ is a valid int value.
a. 46,259 c. 462.59
b. 46259 d. -32.00
|
B
|
____ is a valid char value.
a. -129 c. 128
b. ‘A’ d. 129
|
‘A’
|
An example of a floating point data type is ____.
a. int c. double
b. char d. short
|
double
|
The memory allocated for a float value is ____ bytes.
a. two c. eight
b. four d. sixteen
|
four
|
The value of the expression 33/10, assuming both values are integral data types, is ____.
a. 0.3 c. 3.0
b. 3 d. 3.3
|
3
|
The value of the expression 17 % 7 is ____.
|
3
|
The expression static_cast<int>(9.9) evaluates to ____.
a. 9 c. 9.9
b. 10 d. 9.0
|
9
|
The expression static_cast<int>(6.9) + static_cast<int>(7.9) evaluates to ____.
a. 13 c. 14.8
b. 14 d. 15
|
13
|
The length of the string "computer science" is ____.
a. 14 c. 16
b. 15 d. 18
|
16
|
In a C++ program, one and two are double variables and input values are 10.5 and 30.6.
After the statement cin >> one >> two; executes, ____.
a. one = 10.5, two = 10.5 c. one = 30.6, two = 30.6
b. one = 10.5, two = 30.6 d. one = 11, two = 31
|
B
|
Suppose that count is an int variable and count = 1. After the statement count++;
executes, the value of count is ____.
a. 1 c. 3
b. 2 d. 4
|
2
|
Suppose that alpha and beta are int variables. The statement alpha = –beta; is equivalent
to the statement(s) ____.
a. alpha = 1 – beta;
b. alpha = beta – 1;
c. beta = beta – 1;
alpha = beta;
d. alpha = beta;
beta = beta – 1;
|
C
|
Suppose that alpha and beta are int variables. The statement alpha = beta–; is equivalent
to the statement(s) ____.
a. alpha = 1 – beta;
b. alpha = beta – 1;
c. beta = beta – 1;
alpha = beta;
d. alpha = beta;
beta = beta – 1;
|
D
|
Suppose that alpha and beta are int variables. The statement alpha = beta++; is equivalent
to the statement(s) ____.
a. alpha = 1 + beta;
b. alpha = alpha + beta;
c. alpha = beta;
beta = beta + 1;
d. beta = beta + 1;
alpha = beta;
|
C
|
Suppose that alpha and beta are int variables. The statement alpha = ++beta; is equivalent
to the statement(s) ____.
a. beta = beta + 1;
alpha = beta;
b. alpha = beta;
beta = beta + 1;
c. alpha = alpha + beta;
d. alpha = beta + 1;
|
A
|
Choose the output of the following C++ statement:
cout << "Sunny " << ‘\n’ << "Day " << endl;
a. Sunny \nDay
b. Sunny \nDay endl
c. Sunny
Day
d. Sunny \n
Day
|
C
|
Which of the following is the newline character?
|
\n
|
Consider the following code.
// Insertion Point 1
using namespace std;
const float PI = 3.14;
int main()
{
//Insertion Point 2
float r = 2.0;
float area;
area = PI <b> r </b> r;
cout << "Area = " << area <<endl;
return 0;
}
// Insertion Point 3
In this code, where does the include statement belong?
a. Insertion Point 1 c. Insertion Point 3
b. Insertion Point 2 d. Anywhere in the program
|
A
|
____ are executable statements that inform the user what to do.
a. Variables c. Named constants
b. Prompt lines d. Expressions
|
Prompt lines
|
The declaration int a, b, c; is equivalent to which of the following?
a. inta , b, c; c. int abc;
b. int a,b,c; d. int a b c;
|
B
|
Suppose that alpha and beta are int variables and alpha = 5 and beta = 10. After
the statement alpha *= beta; executes, ____.
a. alpha = 5 c. alpha = 50
b. alpha = 10 d. alpha = 50.0
|
C
|
Suppose that sum and num are int variables and sum = 5 and num = 10. After the
statement sum += num executes, ____.
a. sum = 0 c. sum = 10
b. sum = 5 d. sum = 15
|
D
|
Suppose that x is an int variable and y is a double variable and the input is:
10 20.7
Choose the values after the following statement executes: cin >> x >> y;.
a. x = 10, y = 20 c. x = 10, y = 20.7
b. x = 10, y = 20.0 d. x = 10, y = 21.0
|
C
|
Suppose that x and y are int variables. Which of the following is a valid input statement?
a. cin >> x >> cin >> y; c. cin << x << y;
b. cin >> x >> y; d. cout << x << y;
|
B
|
Suppose that x is an int variable, y is a double variable and ch is a char variable and the input is:
15A 73.2
Choose the values after the following statement executes:
cin >> x >> ch >> y;
a. x = 15, ch = ‘A’, y = 73.2
b. x = 15, ch = ‘A’, y = 73.0
c. x = 15, ch = ‘a’, y = 73.0
d. This statement results in an error because there is no space between 15 and A.
|
A
|
Suppose that alpha is an int variable and ch is a char variable and the input is:
17 A
What are the values after the following statements execute?
cin >> alpha;
cin >> ch;
a. alpha = 17, ch = ‘ ‘ c. alpha = 17, ch = ‘A’
b. alpha = 1, ch = 7 d. alpha = 17, ch = ‘a’
|
C
|
Suppose that x is an int variable, y is a double variable, z is an int variable, and the input is:
15 76.3 14
Choose the values after the following statement executes:
cin >> x >> y >> z;
a. x = 15, y = 76, z = 14
b. x = 15, y = 76, z = 0
c. x = 15, y = 76.3, z = 14
d. x = 15.0, y = 76.3, z = 14.0
|
C
|
Suppose that ch1, ch2, and ch3 are variables of the type char and the input is:
A B
C
Choose the value of ch3 after the following statement executes:
cin >> ch1 >> ch2 >> ch3;
|
C
|
Suppose that x and y are int variables, z is a double variable, and the input is:
28 32.6 12
Choose the values of x, y, and z after the following statement executes:
cin >> x >> y >> z;
a. x = 28, y = 32, z = 0.6
b. x = 28, y = 32, z = 12.0
c. x = 28, y = 12, z = 32.6
d. x = 28, y = 12, z = 0.6
|
B
|
Suppose that x is an int variable, ch is a char variable, and the input is:
276.
Choose the values after the following statement executes:
cin >> ch >> x;
a. ch = ‘2’, x = 276 c. ch = ‘ ‘, x = 276
b. ch = ‘276’, x = ‘.’ d. ch = ‘2’, x = 76
|
D
|
Suppose that x and y are int variables, ch is a char variable, and the input is:
4 2 A 12
Choose the values of x, y, and ch after the following statement executes:
cin >> x >> ch >> y;
a. x = 4, ch = 2, y = 12 c. x = 4, ch = ‘ ‘, y = 2
b. x = 4, ch = A, y = 12 d. This statement results in input failure
|
D
|
Suppose that ch1 and ch2 are char variables, alpha is an int variable, and the input is:
A 18
What are the values after the following statement executes?
cin.get(ch1);
cin.get(ch2);
cin >> alpha;
a. ch1 = ‘A’, ch2 = ‘ ‘, alpha = 18
b. ch1 = ‘A’, ch2 = ‘1’, alpha = 8
c. ch1 = ‘A’, ch2 = ‘ ‘, alpha = 1
d. ch1 = ‘A’, ch2 = ‘\n’, alpha = 1
|
A
|
Suppose that ch1, ch2, and ch3 are variables of the type char and the input is:
A B
C
What is the value of ch3 after the following statements execute?
cin.get(ch1);
cin.get(ch2);
cin.get(ch3);
|
‘B’
|
When you want to process only partial data, you can use the stream function ____ to discard a portion
of the input.
a. clear c. delete
b. skip d. ignore
|
D
|
Suppose that alpha, beta, and gamma are int variables and the input is:
100 110 120
200 210 220
300 310 320
What is the value of gamma after the following statements execute?
cin >> alpha;
cin.ignore(100, ‘\n’);
cin >> beta;
cin.ignore(100,’\n’);
cin >> gamma;
a. 100 c. 300
b. 200 d. 320
|
C
|
Suppose that ch1 and ch2 are char variables and the input is:
WXYZ
What is the value of ch2 after the following statements execute?
cin.get(ch1);
cin.putback(ch1);
cin >> ch2;
a. W c. Y
b. X d. Z
|
A
|
Suppose that ch1 and ch2 are char variables and the input is:
WXYZ
What is the value of ch2 after the following statements execute?
cin >> ch1;
ch2 = cin.peek();
cin >> ch2;
a. W c. Y
b. X d. Z
|
B
|
In C++, the dot is an operator called the ____ operator.
a. dot access c. data access
b. member access d. member
|
B
|
Suppose that x = 25.67, y = 356.876, and z = 7623.9674. What is the output of the
following statements?
cout << fixed << showpoint;
cout << setprecision(2);
cout << x << ‘ ‘ << y << ‘ ‘ << z << endl;
a. 25.67 356.87 7623.96
c. 25.67 356.88 7623.97
b. 25.67 356.87 7623.97
d. 25.67 356.876 7623.967
|
C
|
Suppose that x = 55.68, y = 476.859, and z = 23.8216. What is the output of the
following statements?
cout << fixed << showpoint;
cout << setprecision(3);
cout << x << ‘ ‘ << y << ‘ ‘ << setprecision(2) << z << endl;
a. 55.680 476.859 23.82
c. 55.680 476.860 23.82
b. 55.690 476.860 23.82
d. 55.680 476.859 23.821
|
A
|
Suppose that x = 1565.683, y = 85.78, and z = 123.982. What is the output of the
following statements?
cout << fixed << showpoint;
cout << setprecision(3) << x << ‘ ‘;
cout << setprecision(4) << y << ‘ ‘ << setprecision(2) << z << endl;
a. 1565.683 85.8000 123.98
c. 1565.683 85.7800 123.98
b. 1565.680 85.8000 123.98
d. 1565.683 85.780 123.980
|
C
|
What is the output of the following statements?
cout << setfill(‘*’);
cout << "12345678901234567890" << endl
cout << setw(5) << "18" << setw(7) << "Happy"
<< setw(8) << "Sleepy" << endl;
a. 12345678901234567890
***18 Happy Sleepy
b. 12345678901234567890
**<b>18</b><b>Happy</b>*Sleepy
c. 12345678901234567890
**<b>18</b>*Happy Sleepy
d. 12345678901234567890
**<b>18</b><b>Happy Sleepy</b>*
|
B
|
What is the output of the following statements?
cout << "123456789012345678901234567890" << endl
cout << setfill(‘#’) << setw(10) << "Mickey"
<< setfill(‘ ‘) << setw(10) << "Donald"
<< setfill(‘*’) << setw(10) << "Goofy" << endl;
a. 123456789012345678901234567890
####Mickey Donald*****Goofy
b. 123456789012345678901234567890
####Mickey####Donald*****Goofy
c. 123456789012345678901234567890
####Mickey####Donald#####Goofy
d. 23456789012345678901234567890
****Mickey####Donald#####Goofy
|
A
|
____ is a parameterized stream manipulator.
a. endl c. scientific
b. fixed d. setfill
|
D
|
Manipulators without parameters are part of the ____ header file.
a. iostream c. ifstream
b. iomanip d. pmanip
|
A
|
Consider the following program segment.
ifstream inFile; //Line 1
int x, y; //Line 2
… //Line 3
inFile >> x >> y; //Line 4
Which of the following statements at Line 3 can be used to open the file progdata.dat and input
data from this file into x and y at Line 4?
a. inFile.open("progdata.dat");
b. inFile(open,"progdata.dat");
c. open.inFile("progdata.dat");
d. open(inFile,"progdata.dat");
|
A
|
Suppose that outFile is an ofstream variable and output is to be stored in the file
outputData.out. Which of the following statements opens the file outputData.out and
associates outFile to the output file?
a. outFile("outputData.out");
b. outFile.open("outputData.out");
c. open(outFile,"outputData.out");
d. open.outFile("outputData.out");
|
B
|
In a ____ control structure, the computer executes particular statements depending on some
condition(s).
a. looping c. selection
b. repetition d. sequence
|
C
|
What does <= mean?
a. less than c. less than or equal to
b. greater than d. greater than or equal to
|
C
|
Which of the following is a relational operator?
a. = c. !
b. == d. &&
|
B
|
Which of the following is the "not equal to" relational operator
|
!=
|
Suppose x is 5 and y is 7. Choose the value of the following expression:
(x != 7) && (x <= y)
a. false c. 0
b. true d. null
|
B
|
Suppose that x is an int variable. Which of the following expressions always evaluates to true?
a. (x > 0) || ( x <= 0) c. (x > 0) && ( x <= 0)
b. (x >= 0) || (x == 0)
d. (x > 0) && (x == 0)
|
A
|
Which of the following operators has the highest precedence?
a. ! c. %
b. * d. =
|
A
|
Which of the following operators has the lowest precedence?
a. ! c. &&
b. || d. =
|
D
|
Which of the following expressions correctly determines that x is greater than 10 and less than
20?
a. 10 < x < 20
c. 10 < x && x < 20
b. (10 < x < 20)
d. 10 < x || x < 20
|
C
|
The expression in an if statement is sometimes called a(n) ____.
a. selection statement c. decision maker
b. action statement d. action maker
|
C
|
What is the output of the following C++ code?
int x = 35;
int y = 45;
int z;
if (x > y)
z = x + y;
else
z = y – x;
cout << x << " " << y << " " << z << endl;
a. 35 45 80
c. 35 45 -10
b. 35 45 10
d. 35 45 0
|
B
|
When one control statement is located within another, it is said to be ____.
a. blocked c. nested
b. compound d. closed
|
C
|
What is the output of the following code?
if (6 > 8)
{
cout << " ** " << endl ;
cout << "****" << endl;
}
else if (9 == 4)
cout << "***" << endl;
else
cout << "*" << endl;
a. <b> c. </b>**
b. *<b> d. </b>***
|
A
|
Which of the following will cause a logical error if you are attempting to compare x to 5?
a. if (x == 5)
c. if (x <= 5)
b. if (x = 5)
d. if (x >= 5)
|
B
|
The appearance of = in place of == resembles a(n) ____.
a. syntax error c. compilation error
b. silent killer d. input failure
|
B
|
Assume you have three int variables: x = 2, y = 6, and z. Choose the value of z in the
following expression: z = (y / x > 0) ? x : y;.
a. 2 c. 4
b. 3 d. 6
|
A
|
The conditional operator ?: takes ____ arguments.
a. two c. four
b. three d. five
|
B
|
What is the value of x after the following statements execute?
int x;
x = (5 <= 3 && ‘A’ < ‘F’) ? 3 : 4
a. 2 c. 4
b. 3 d. 5
|
C
|
To develop a program, you can use an informal mixture of C++ and ordinary language, called ____.
a. assert code c. cppcode
b. pseudocode d. source code
|
B
|
What is the output of the following code?
char lastInitial = ‘S’;
switch (lastInitial)
{
case ‘A’:
cout << "section 1" <<endl;
break;
case ‘B’:
cout << "section 2" <<endl;
break;
case ‘C’:
cout << "section 3" <<endl;
break;
case ‘D’:
cout << "section 4" <<endl;
break;
default:
cout << "section 5" <<endl;
}
a. section 2
c. section 4
b. section 3
d. section 5
|
D
|
What is the output of the following code?
char lastInitial = ‘A’;
switch (lastInitial)
{
case ‘A’:
cout << "section 1" <<endl;
break;
case ‘B’:
cout << "section 2" <<endl;
break;
case ‘C’:
cout << "section 3" <<endl;
break;
case ‘D’:
cout << "section 4" <<endl;
break;
default:
cout << "section 5" <<endl;
}
a. section 1
c. section 3
b. section 2
d. section 5
|
A
|
What is the output of the following code fragment if the input value is 4?
int num;
int alpha = 10;
cin >> num;
switch (num)
{
case 3:
alpha++;
break;
case 4:
case 6:
alpha = alpha + 3;
case 8:
alpha = alpha + 4;
break;
default:
alpha = alpha + 5;
}
cout << alpha << endl;
a. 13 c. 17
b. 14 d. 22
|
C
|
What is the output of the following C++ code?
int x = 55;
int y = 5;
switch (x % 7)
{
case 0:
case 1:
y++;
case 2:
case 3:
y = y + 2;
case 4:
break;
case 5:
case 6:
y = y – 3;
}
cout << y << endl;
a. 2 c. 8
b. 5 d. 10
|
A
|
For a program to use the assert function, it must include which of the following?
a. #include <assert> c. #include <assertc>
b. #include <cassert>
d. #include NDEBUG
|
B
|
You can disable assert statements by using which of the following?
a. #include <cassert>
c. #clear NDEBUG
b. #define <assert> d. #define NDEBUG
|
D
|
In ____ structures, the computer repeats particular statements a certain number of times depending on
some condition(s).
a. looping
c. selection
b. branching
d. sequence
|
A
|
What is the output of the following C++ code?
count = 1;
num = 25;
while (count < 25)
{
num = num – 1;
count++;
}
cout << count << " " << num << endl;
a. 24 0 c. 25 0
b. 24 1 d. 25 1
|
D
|
What is the output of the following C++ code?
num = 10;
while (num > 10)
num = num – 2;
cout << num << endl;
a. 0 c. 8
b. 6 d. 10
|
D
|
What is the output of the following C++ code?
num = 100;
while (num <= 150)
num = num + 5;
cout << num << endl;
a. 150 c. 160
b. 155 d. 165
|
B
|
A loop that continues to execute endlessly is called a(n) ____ loop.
a. end c. infinite
b. unhinged
d. definite
|
C
|
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.
a. flag-controlled c. EOF-controlled
b. counter-controlled d. sentinel-controlled
|
B
|
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;
a. 92 c. 110
b. 109 d. 119
|
C
|
A(n) ____-controlled while loop uses a bool variable to control the loop.
a. counter c. flag
b. sentinel d. EOF
|
C
|
Which of the following statements generates a random number between 0 and 50?
a. srand(time(0));
num = rand() % 50;
c. srand(time(0));
num = rand()50;
b. srand(time(10));
num = rand()/50;
d. srand(time(10));
num = rand() % 50;
|
A
|
Consider the following code. (Assume that all variables are properly declared.)
cin >> ch;
while (cin)
{
cout << ch;
cin >> ch;
}
This code is an example of a(n) ____ while loop.
a. sentinel-controlled
c. EOF-controlled
b. flag-controlled
d. counter-controlled
|
C
|
What is the next Fibonacci number in the following sequence?
1, 1, 2, 3, 5, 8, 13, 21, …
a. 34 c. 56
b. 43 d. 273
|
A
|
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;
a. i = 1; c. i++;
b. i < 20;
d. cout << "Hello World";
|
A
|
What is the output of the following C++ code?
int j;
for (j = 10; j <= 10; j++)
cout << j << " ";
cout << j << endl;
a. 10 c. 10 11
b. 10 10 d. 11 11
|
C
|
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;
a. 24 c. 41
b. 25 d. 42
|
A
|
Suppose j, sum, and num are int variables, and the input is 26 34 61 4 -1. What is the output
of the code?
sum = 0;
cin >> num;
for (int j = 1; j <= 4; j++)
{
sum = sum + num;
cin >> num;
}
cout << sum << endl;
a. 124 c. 126
b. 125 d. 127
|
B
|
Which of the following is a repetition structure in C++?
a. if
c. while…do
b. switch
d. do…while
|
D
|
Which executes first in a do…while loop?
a. the statement
c. the expression
b. loop condition
d. update statement
|
A
|
What is the value of x after the following statements execute?
int x = 5;
int y = 30;
do
x = x * 2;
while (x < y);
a. 5 c. 20
b. 10 d. 40
|
D
|
What is the output of the following loop?
count = 5;
cout << ‘St’;
do
{
cout << ‘o’;
count–;
}
while (count <= 5);
a. St c. Stop
b. Sto d. This is an infinite loop.
|
D
|
____ loops are called posttest loops.
a. break c. while
b. for d. do…while
|
D
|
Which of the following loops is guaranteed to execute at least once?
a. counter-controlled while loop c. do…while loop
b. for loop d. sentinel-controlled while loop
|
C
|
Which of the following loops does not have an entry condition?
a. EOF-controlled while loop c. do…while loop
b. sentinel-controlled while loop d. for loop
|
C
|
The ____ statement can be used to eliminate the use of certain (flag) variables.
a. while c. break
b. switch d. if
|
C
|
What executes immediately after a continue statement in a while and do-while loop?
a. loop-continue test c. loop condition
b. update statement d. the body of the loop
|
A
|
When a continue statement is executed in a ____, the update statement always executes.
a. while loop
c. switch structure
b. for loop
d. do…while loop
|
B
|
The standard header file for the abs(x)function is ____.
a. <cmath>
c. <cctype>
b. <ioinput>
d. <cstdlib>
|
A
|
To use the predefined function tolower, the program must include the header file ____.
a. <cctype>
c. <cmath>
b. <iostream>
d. <cstdlib>
|
A
|
The output of the statement:
cout << tolower(‘$’) << endl;
is ____.
a. ‘$’
b. ‘0’
c. ‘1’
d. An error, because you cannot use tolower with ‘$’.
|
A
|
Assume the following.
static_cast<int>(‘a’) = 97
static_cast<int>(‘A’) = 65
The output of the statement:
cout << static_cast<int>(tolower(‘B’)) << endl; is ____.
a. 65 c. 96
b. 67 d. 98
|
D
|
The output of the statement: cout << pow(3.0, 2.0) + 5 << endl; is ____.
a. 11.0 c. 13.0
b. 12.0 d. 14.0
|
D
|
The output of the statement:
cout << pow(2.0, pow(3.0, 1.0)) << endl;
is ____.
a. 6.0 c. 8.0
b. 7.0 d. 9.0
|
C
|
Functions that do not have a return type are called ____ functions.
a. zero c. void
b. null d. empty
|
C
|
The heading of the function is also called the ____.
a. title
c. function head
b. function signature d. function header
|
D
|
A variable or expression listed in a call to a function is called the ____.
a. formal parameter c. data type
b. actual parameter d. type of the function
|
B
|
A variable listed in a header is known as a(n) ____ parameter.
a. actual c. formal
b. local d. function
|
C
|
Given the following function:
int next(int x)
{
return (x + 1);
}
what is the output of the following statement?
cout << next(next(5)) << endl;
a. 5 c. 7
b. 6 d. 8
|
C
|
Which statement below about prototypes and headers is true?
a. Parameter names must be listed in the prototype, but not necessarily in the header.
b. Prototypes end with a semicolon, but headers do not.
c. Headers should come before prototypes.
d. Headers end with a semicolon, but prototypes do not
|
B
|
Given the following function prototype: int test(float, char);, which of the following
statements is valid?
a. cout << test(12, &);
b. cout << test("12.0", ‘&’);
c. int u = test(5.0, ‘*’);
d. cout << test(’12’, ‘&’);
|
C
|
A function prototype is ____.
a. a definition, but not a declaration c. a declaration, but not a definition
b. a declaration and a definition d. a comment line
|
C
|
Given the following function prototype: double tryMe(double, double);, which of the
following statements is valid? Assume that all variables are properly declared.
a. cin >> tryMe(x);
b. cout << tryMe(2.0, 3.0);
c. cout << tryMe(tryMe(double, double), double);
d. cout << tryMe(tryMe(float, float), float);
|
B
|
Given the function prototype: double testAlpha(int u, char v, double t); which
of the following statements is legal?
a. cout << testAlpha(5, ‘A’, 2);
b. cout << testAlpha( int 5, char ‘A’, int 2);
c. cout << testAlpha(‘5.0’, ‘A’, ‘2.0’);
d. cout << testAlpha(5.0, "65", 2.0);
|
A
|
Given the function prototype:
float test(int, int, int);
which of the following statements is legal?
a. cout << test(7, test(14, 23));
b. cout << test(test(7, 14), 23);
c. cout << test(14, 23);
d. cout << test(7, 14, 23);
|
D
|
Which of the following function prototypes is valid?
a. int funcTest(int x, int y, float z){}
b. funcTest(int x, int y, float){};
c. int funcTest(int, int y, float z)
d. int funcTest(int, int, float);
|
D
|
Which of the following function prototypes is valid?
a. int funcExp(int x, float v);
b. funcExp(int x, float v){};
c. funcExp(void);
d. int funcExp(x);
|
A
|
Given the following function prototype: int myFunc(int, int);, which of the following
statements is valid? Assume that all variables are properly declared.
a. cin >> myFunc(y);
b. cout << myFunc(myFunc(7, 8), 15);
c. cin >> myFunc(‘2’, ‘3’);
d. cout << myFunc(myFunc(7), 15);
|
B
|
The statement: return 8, 10; returns the value ____.
a. 8 c. 18
b. 10 d. 80
|
B
|
The statement: return 37, y, 2 * 3; returns the value ____.
a. 2 c. y
b. 3 d. 6
|
D
|
The statement: return 2 * 3 + 1, 1 + 5; returns the value ____.
a. 2 c. 6
b. 3 d. 7
|
C
|
Given the following function:
int strange(int x, int y)
{
if (x > y)
return x + y;
else
return x – y;
}
what is the output of the following statement?
cout << strange(4, 5) << endl;
a. -1 c. 9
b. 1 d. 20
|
A
|
What value is returned by the following return statement?
int x = 5;
return x + 1;
a. 0 c. 6
b. 5 d. 7
|
C
|
A(n) ____ is an occurrence of an undesirable situation that can be detected during program execution.
a. crash c. misfire
b. exception d. bug
|
B
|
The function ____ can check whether an expression meets the required conditions; if the conditions
are not met, it terminates the program.
a. check c. assert
b. look d. what
|
C
|
When division by zero occurs and the problem is not addressed, the program crashes with an error
message that is ____ dependent.
a. code c. platform
b. computer d. IDE
|
D
|
To use the assert function in your program, you should include the statement ____.
a. #include <assert> c. #include <iostream>
b. #include <cassert> d. #include <exception>
|
B
|
Which of the following is a valid C++ statement?
a. assert(0 = divisor); c. assert(divisor 0);
b. assert(divisor != 0); d. assert(divisor is 0);
|
B
|
The statements that may generate an exception are placed in a ____ block.
a. throw c. try
b. finally d. catch
|
C
|
The try block is followed by one or more ____ blocks.
a. throw c. do
b. finally d. catch
|
D
|
Which of the following blocks is designed to catch any type of exception?
a. catch(){ }
c. catch(*){ }
b. catch(…){ }
d. catch(exception){
|
B
|
A catch block can have, at most, ____ catch block parameter(s).
a. zero c. two
b. one d. three
|
B
|
Which of the following statements throws a valid exception in C++?
a. throw.function(); c. throws str;
b. throw 2;
d. 4 throw;
|
B
|
In a sequence of try/catch blocks, the last catch block of that sequence should be ____.
a. catch(…){ }
c. catch(str){ }
b. catch(int x){ }
d. catch(exception){}
|
A
|
The class ____ is the base of the classes designed to handle exceptions.
a. class
c. logic_error
b. exception
d. runtime_error
|
B
|