Quiz 2 Flashcards

1
Q

A statement that starts with a # symbol is called a:

A

A) Comment

B) Function

*C) Preprocessor directive

D) Key word

E) None of the above

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

The ________ is/are used to display information on the computer’s screen.

A

A) Opening and closing braces

B) Opening and closing quotation marks

*C) cout object

D) Backslash

E) None of the above

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

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

A

A) Backslash

B) Forwardslash

C) Semicolon

*D) #include directive

E) None of the above

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

These are data items whose values do not change while the program is running.

A

*A) Literals

B) Variables

C) Comments

D) Integers

E) None of the above

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

You must have a ________ for every variable you intend to use in a program.

A

A) purpose

*B) definition

C) comment

D) constant

E) None of the above

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

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

A

A) double, single

B) triple, double

C) open, closed

*D) single, double

E) None of the above

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Which data type typically requires only one byte of storage?

A

A) short

B) int

C) float

*D) char

E) double

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

In programming terms, a group of characters inside a set of quotation marks is called a(n):

A

*A) String literal

B) Variable

C) Operation

D) Statement

E) None of the above

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

This is used to mark the end of a complete C++ programming statement.

A

A) Pound Sign

*B) Semicolon

C) Data type

D) Void

E) None of the above

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Which character signifies the beginning of an escape sequence?

A

A) //

B) /

*C) \

D) #

E) {

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

________ must be included in any program that uses the cout object.

A

A) Opening and closing braces

*B) The header file iostream

C) Comments

D) Escape sequences

E) None of the above

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

This function in C++ allows you to identify how many bytes of storage on your computer system an integer data value requires.

A

A) len

B) bytes

C) f(x)

D) int

*E) sizeof

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

A variable whose value can be either true or false is of this data type.

A

A) binary

*B) bool

C) T/F

D) float

E) None of the above

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Which of the following correctly consolidates the following declaration statements into one statement?

 int x = 7;

 int y = 16;

 int z = 28;
A

A) int x = 7; y = 16; z = 28;

B) int x = 7 y = 16 z = 28;

C) int x, y, z = 7, 16, 28

*D) int x = 7, y = 16, z = 28;

E) None of these will work.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

A variable’s ________ is the part of the program that has access to the variable.

A

A) data type

B) value

*C) scope

D) reach

E) None of the above

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Every complete C++ program must have a ________.

A

A) comment

*B) function named main

C) preprocessor directive

D) symbolic constant

E) cout statement

17
Q

Which one of the following would be an illegal variable name?

A

A) dayOfWeek

*B) 3dGraph

C) _employee_num

D) June1997

E) itemsorderedforthemonth

18
Q

What will the following code display?

 cout << "Monday";

 cout << "Tuesday";

 cout << "Wednesday";
A

A) Monday

Tuesday

Wednesday

B) Monday Tuesday Wednesday

*C) MondayTuesdayWednesday

D) “Monday”

“Tuesday”

“Wednesday”

19
Q

What will the following code display?

 int number = 7;

 cout << "The number is " << "number" << endl;
A

A) The number is 7

*B) The number is number

C) The number is7

D) The number is 0

20
Q

What will the following code display?

 int x = 0, y = 1, z = 2;

 cout << x << y << z << endl;
A

A) 0 1 2

B) 0

1

2

C) xyz

*D) 012

21
Q

What will the following code display?

 cout << "Four\n" << "score\n";

 cout << "and" << "\nseven";

 cout << "\nyears" << " ago" << endl;
A

*A) Four

score

and

seven

years ago

B) Four score and seven

years ago

C) Four

score

and seven

years ago

D) Four score

and seven

years ago

22
Q

Assume that a program has the following variable definition:

 char letter;

Which of the following statements correctly assigns the character Z to the variable?

A

A) letter = Z;

B) letter = “Z”;

*C) letter = ‘Z’;

D) letter = (Z);

23
Q

What will the value of x be after the following statements execute?

 int x;

 x = 18 / 4;
A

A) 4.5

*B) 4

C) 0

D) unknown

24
Q

What will the value of x be after the following statements execute?

 int x;

 x = 18.0 / 4;
A

A) 4.5

*B) 4

C) 0

D) unknown

25
Q

What will the value of x be after the following statements execute?

 int x;

 x = 18 % 4;
A

A) 0.45

B) 4

*C) 2

D) unknown