Computer Science - Chapter 2

Program style refers to the way a programmer uses:

Identifiers, spaces, tabs, blank lines, and punctuation

If a float variable does not have enough precision to store a particular number, you should store the number as a

double

True/False: An escape sequence must start with a forward slash (/) .

FALSE

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

String constant

The numeric data types in C++ are broken into two categories:

integer and floating-point

A statement that starts with a # is called a:

Preprocessor directive

True/False: The amount of storage space required by the C++ data types depends upon the particular compiler you are using.

TRUE

In the broadest sense, C++ has just 2 basic data types:

numeric and character

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

#include directive

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

single, double

True/False: A preprocessor directive always begins with a double slash ( // ).

FALSE

True/False: The following statements could be used interchangeably in a C++ program.
// Program Payroll
/
Program Payroll
/

TRUE

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

Semicolon

True/False: A preprocessor directive does not require a semicolon at the end.

TRUE

The expression 5 / 2 evaluates to

2

The expression 5 % 2 evaluates to

1

In a C++ program, two slash marks ( // ) indicate:

The beginning of a comment

True/False: C++ is a case-sensitive language

TRUE

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

Constants

True/False: The following statements both declare the variable num to be an integer.
int num;
INT num;

FALSE

For every opening brace in a C++ program, there must be a:

Closing brace

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

Definition

The bool data type

has only two values: true and false

___________ data types are used to declare variables that can hold real numbers.

Floating-point

The ______ is/are used to display information on the computer's screen.

cout object

True/False: The following is a legal C++ statement to define and initialize a variable.
char firstName = "Jack";

FALSE

C++ automatically places the ___________ at the end of string constants.

Null terminator

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

The iostream header file

True/False: If number has been defined as an int variable, both of the following statements will print out its value:
cout << number;
cout << "number";

FALSE

True/False: Variables represent storage locations in the computer's memory.

TRUE

Besides decimal, two other number systems you might encounter in C++ programs are:

Hexadecimal and Octal

True/False: A variable called average should be declared as an integer data type because it will probably hold data that contains decimal places.

FALSE

True/False: The following two C++ statements are identical:
regWages = regPay + overTime;
regPay + overTime = regWages;

FALSE