Starting out with C++ Chapter 2 Quiz

¡Supera tus tareas y exámenes ahora con Quizwiz!

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

#include directive

The first step in using the string class is to #include the ________ header file.

string

________ represent storage locations in the computer's memory.

variables

These are used to declare variables that can hold real numbers.

Floating point data types

What will the following code display? cout << "Four " << "score "; cout << "and " << "seven/n"; cout << "years" << "ago" << endl;

Four score and seven/nyearsago

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

Preprocessor directive

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

The beginning of a comment

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

The header file iostream

The numeric data types in C++ can be broken into two general categories:

integer and floating point

In C++ 11, if you want an integer literal to be treated as a long long int, you can append ________ at the end of the number.

LL

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

definition

A string literal is enclosed in ________ quotation marks.

double

Which of the following correctly consolidates the following declaration statements into one statement? int x = 7; int y = 16; int z = 28;

int x = 7, y = 16, z = 28;

Assume that a program has the following variable definition: char letter; Which of the following statements correctly assigns the character Z to the variable?

letter = 'Z';

If you use a C++ key word as an identifier, your program will:

not compile

What will the value of x be after the following statements execute? int x; x = 18 % 4;

2

Look at the following program and answer the question that follows it. 1 // This program displays my gross wages. 2 // I worked 40 hours and I make $20.00 per hour. 3 #include <iostream> 4 using namespace std; 5 6 int main() 7 { 8 int hours; 9 double payRate, grossPay; 10 11 hours = 40; 12 payRate = 20.0; 13 grossPay = hours * payRate; 14 cout << "My gross pay is $" << grossPay << endl; 15 return 0; 16 } Which line(s) in this program cause output to be displayed on the screen?

14

What is the value of cookies after the execution of the following statements? int number = 38, children = 4, cookies; cookies = number % children;

2

In C++ 11, the ________ tells the compiler to determine the variable's data type from the initialization value.

auto key word

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

bool

Which data type typically requires only one byte of storage?

char

Assume that a program has the following string object definition: string name; Which of the following statements correctly assigns a string literal to the string object?

name = "Jane";

In memory, C++ automatically places a ________ at the end of string literals.

null terminator

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

sizeof

int x = 0, y = 1, z = 2; cout << x << y << z << endl;

012

What is the output of the following statement? cout << 4 * (15 / (1 + 3)) << endl;

12

What will the value of x be after the following statements execute? int x; x = 18 / 4;

4

What will the value of x be after the following statements execute? int x; x = 18.0 / 4;

4

What will the following code display? int number = 7; cout << "The number is " << "number" << endl;

The number is number

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

scope

A character literal is enclosed in ________ quotation marks.

single


Conjuntos de estudio relacionados

Chapter 3: Probability and Sampling

View Set

chapter 13: mktg services: the intangible product

View Set

70-646 Testlet School of Fine Art

View Set

Chapter 11: International Banking and Money Market

View Set

Met Physics 2 Final HW questions

View Set

The Call of the Wild Chapter 4 review

View Set

Saunders NCLEX-RN - Hypersensitivity Reactions and Allergy, Acute Kidney Injury, Chronic Kidney Disease

View Set