C++ Test prep

Your page rank:

Total word count: 5549
Pages: 20

Calculate the Price

- -
275 words
Looking for Expert Opinion?
Let us have a look at your work and suggest how to improve it!
Get a Consultant

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 &lt;&lt; "Area = " &lt;&lt; area &lt;&lt;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 &gt;&gt; x &gt;&gt; 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 &gt;&gt; x &gt;&gt; cin &gt;&gt; y; c. cin &lt;&lt; x &lt;&lt; y;
b. cin &gt;&gt; x &gt;&gt; y; d. cout &lt;&lt; x &lt;&lt; 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 &gt;&gt; x &gt;&gt; ch &gt;&gt; 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 &gt;&gt; alpha;
cin &gt;&gt; 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 &gt;&gt; x &gt;&gt; y &gt;&gt; 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 &gt;&gt; ch1 &gt;&gt; ch2 &gt;&gt; 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 &gt;&gt; x &gt;&gt; y &gt;&gt; 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 &gt;&gt; ch &gt;&gt; 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 &gt;&gt; x &gt;&gt; ch &gt;&gt; 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 &gt;&gt; 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 &gt;&gt; alpha;
cin.ignore(100, ‘\n’);
cin &gt;&gt; beta;
cin.ignore(100,’\n’);
cin &gt;&gt; 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 &gt;&gt; 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 &gt;&gt; ch1;
ch2 = cin.peek();
cin &gt;&gt; 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 &lt;&lt; fixed &lt;&lt; showpoint;
cout &lt;&lt; setprecision(2);
cout &lt;&lt; x &lt;&lt; ‘ ‘ &lt;&lt; y &lt;&lt; ‘ ‘ &lt;&lt; z &lt;&lt; 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 &lt;&lt; fixed &lt;&lt; showpoint;
cout &lt;&lt; setprecision(3);
cout &lt;&lt; x &lt;&lt; ‘ ‘ &lt;&lt; y &lt;&lt; ‘ ‘ &lt;&lt; setprecision(2) &lt;&lt; z &lt;&lt; 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 &lt;&lt; fixed &lt;&lt; showpoint;
cout &lt;&lt; setprecision(3) &lt;&lt; x &lt;&lt; ‘ ‘;
cout &lt;&lt; setprecision(4) &lt;&lt; y &lt;&lt; ‘ ‘ &lt;&lt; setprecision(2) &lt;&lt; z &lt;&lt; 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 &lt;&lt; setfill(‘*’);
cout &lt;&lt; "12345678901234567890" &lt;&lt; endl
cout &lt;&lt; setw(5) &lt;&lt; "18" &lt;&lt; setw(7) &lt;&lt; "Happy"
&lt;&lt; setw(8) &lt;&lt; "Sleepy" &lt;&lt; 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 &lt;&lt; "123456789012345678901234567890" &lt;&lt; endl
cout &lt;&lt; setfill(‘#’) &lt;&lt; setw(10) &lt;&lt; "Mickey"
&lt;&lt; setfill(‘ ‘) &lt;&lt; setw(10) &lt;&lt; "Donald"
&lt;&lt; setfill(‘*’) &lt;&lt; setw(10) &lt;&lt; "Goofy" &lt;&lt; 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 &gt;&gt; x &gt;&gt; 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 &lt;= 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. &amp;&amp;

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) &amp;&amp; (x &lt;= 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 &gt; 0) || ( x &lt;= 0) c. (x &gt; 0) &amp;&amp; ( x &lt;= 0)
b. (x &gt;= 0) || (x == 0)
d. (x &gt; 0) &amp;&amp; (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. &amp;&amp;
b. || d. =

D

Which of the following expressions correctly determines that x is greater than 10 and less than
20?
a. 10 &lt; x &lt; 20
c. 10 &lt; x &amp;&amp; x &lt; 20
b. (10 &lt; x &lt; 20)
d. 10 &lt; x || x &lt; 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 &gt; y)
z = x + y;
else
z = y – x;
cout &lt;&lt; x &lt;&lt; " " &lt;&lt; y &lt;&lt; " " &lt;&lt; z &lt;&lt; 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 &gt; 8)
{
cout &lt;&lt; " ** " &lt;&lt; endl ;
cout &lt;&lt; "****" &lt;&lt; endl;
}
else if (9 == 4)
cout &lt;&lt; "***" &lt;&lt; endl;
else
cout &lt;&lt; "*" &lt;&lt; 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 &lt;= 5)
b. if (x = 5)
d. if (x &gt;= 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 &gt; 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 &lt;= 3 &amp;&amp; ‘A’ &lt; ‘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 &lt;&lt; "section 1" &lt;&lt;endl;
break;
case ‘B’:
cout &lt;&lt; "section 2" &lt;&lt;endl;
break;
case ‘C’:
cout &lt;&lt; "section 3" &lt;&lt;endl;
break;
case ‘D’:
cout &lt;&lt; "section 4" &lt;&lt;endl;
break;
default:
cout &lt;&lt; "section 5" &lt;&lt;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 &lt;&lt; "section 1" &lt;&lt;endl;
break;
case ‘B’:
cout &lt;&lt; "section 2" &lt;&lt;endl;
break;
case ‘C’:
cout &lt;&lt; "section 3" &lt;&lt;endl;
break;
case ‘D’:
cout &lt;&lt; "section 4" &lt;&lt;endl;
break;
default:
cout &lt;&lt; "section 5" &lt;&lt;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 &gt;&gt; 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 &lt;&lt; alpha &lt;&lt; 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 &lt;&lt; y &lt;&lt; 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 &lt;assert&gt; c. #include &lt;assertc&gt;
b. #include &lt;cassert&gt;
d. #include NDEBUG

B

You can disable assert statements by using which of the following?
a. #include &lt;cassert&gt;
c. #clear NDEBUG
b. #define &lt;assert&gt; 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 &lt; 25)
{
num = num – 1;
count++;
}
cout &lt;&lt; count &lt;&lt; " " &lt;&lt; num &lt;&lt; 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 &gt; 10)
num = num – 2;
cout &lt;&lt; num &lt;&lt; endl;
a. 0 c. 8
b. 6 d. 10

D

What is the output of the following C++ code?
num = 100;
while (num &lt;= 150)
num = num + 5;
cout &lt;&lt; num &lt;&lt; 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 &gt;&gt; limit;
while (reps &lt; limit)
{
cin &gt;&gt; entry;
triple = entry * 3;
cout &lt;&lt; triple;
reps++;
}
cout &lt;&lt; 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 &gt;&gt; num;
while (num != -1)
{
sum = sum + num;
cin &gt;&gt; num;
}
cout &lt;&lt; sum &lt;&lt; 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 &gt;&gt; ch;
while (cin)
{
cout &lt;&lt; ch;
cin &gt;&gt; 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 &lt; 20; i++)
cout &lt;&lt; "Hello World";
cout &lt;&lt; "!" &lt;&lt; endl;
a. i = 1; c. i++;
b. i &lt; 20;
d. cout &lt;&lt; "Hello World";

A

What is the output of the following C++ code?
int j;
for (j = 10; j &lt;= 10; j++)
cout &lt;&lt; j &lt;&lt; " ";
cout &lt;&lt; j &lt;&lt; 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 &gt;&gt; sum;
cin &gt;&gt; num;
for (j = 1; j &lt;= 3; j++)
{
cin &gt;&gt; num;
sum = sum + num;
}
cout &lt;&lt; sum &lt;&lt; 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 &gt;&gt; num;
for (int j = 1; j &lt;= 4; j++)
{
sum = sum + num;
cin &gt;&gt; num;
}
cout &lt;&lt; sum &lt;&lt; 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 &lt; y);
a. 5 c. 20
b. 10 d. 40

D

What is the output of the following loop?
count = 5;
cout &lt;&lt; ‘St’;
do
{
cout &lt;&lt; ‘o’;
count–;
}
while (count &lt;= 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. &lt;cmath&gt;
c. &lt;cctype&gt;
b. &lt;ioinput&gt;
d. &lt;cstdlib&gt;

A

To use the predefined function tolower, the program must include the header file ____.
a. &lt;cctype&gt;
c. &lt;cmath&gt;
b. &lt;iostream&gt;
d. &lt;cstdlib&gt;

A

The output of the statement:
cout &lt;&lt; tolower(‘$’) &lt;&lt; endl;
is ____.
a. ‘$’
b. ‘0’
c. ‘1’
d. An error, because you cannot use tolower with ‘$’.

A

Assume the following.
static_cast&lt;int&gt;(‘a’) = 97
static_cast&lt;int&gt;(‘A’) = 65
The output of the statement:
cout &lt;&lt; static_cast&lt;int&gt;(tolower(‘B’)) &lt;&lt; endl; is ____.
a. 65 c. 96
b. 67 d. 98

D

The output of the statement: cout &lt;&lt; pow(3.0, 2.0) + 5 &lt;&lt; endl; is ____.
a. 11.0 c. 13.0
b. 12.0 d. 14.0

D

The output of the statement:
cout &lt;&lt; pow(2.0, pow(3.0, 1.0)) &lt;&lt; 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 &lt;&lt; next(next(5)) &lt;&lt; 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 &lt;&lt; test(12, &amp;);
b. cout &lt;&lt; test("12.0", ‘&amp;’);
c. int u = test(5.0, ‘*’);
d. cout &lt;&lt; test(’12’, ‘&amp;’);

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 &gt;&gt; tryMe(x);
b. cout &lt;&lt; tryMe(2.0, 3.0);
c. cout &lt;&lt; tryMe(tryMe(double, double), double);
d. cout &lt;&lt; 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 &lt;&lt; testAlpha(5, ‘A’, 2);
b. cout &lt;&lt; testAlpha( int 5, char ‘A’, int 2);
c. cout &lt;&lt; testAlpha(‘5.0’, ‘A’, ‘2.0’);
d. cout &lt;&lt; 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 &lt;&lt; test(7, test(14, 23));
b. cout &lt;&lt; test(test(7, 14), 23);
c. cout &lt;&lt; test(14, 23);
d. cout &lt;&lt; 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 &gt;&gt; myFunc(y);
b. cout &lt;&lt; myFunc(myFunc(7, 8), 15);
c. cin &gt;&gt; myFunc(‘2’, ‘3’);
d. cout &lt;&lt; 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 &gt; y)
return x + y;
else
return x – y;
}
what is the output of the following statement?
cout &lt;&lt; strange(4, 5) &lt;&lt; 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 &lt;assert&gt; c. #include &lt;iostream&gt;
b. #include &lt;cassert&gt; d. #include &lt;exception&gt;

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

Share This
Flashcard

More flashcards like this

NCLEX 10000 Integumentary Disorders

When assessing a client with partial-thickness burns over 60% of the body, which finding should the nurse report immediately? a) ...

Read more

NCLEX 300-NEURO

A client with amyotrophic lateral sclerosis (ALS) tells the nurse, "Sometimes I feel so frustrated. I can’t do anything without ...

Read more

NASM Flashcards

Which of the following is the process of getting oxygen from the environment to the tissues of the body? Diffusion ...

Read more

Unfinished tasks keep piling up?

Let us complete them for you. Quickly and professionally.

Check Price

Successful message
sending