COP1334 C++ Midterm (Ch.2)

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

True

Escape sequences are always stored internally as a single character.

function named main

Every complete C++ program must have a _____________.

C++ identifier

Object, Variable name, class, structure

False

If you do not follow a consistent programming style, your programs will generate compiler errors

Null terminator

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

integer and floating point

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

Literals

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

Floating point data types

These are used to declare variables that can hold real numbers

sizeof

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

Semicolon

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

%

What is the modulus operator?

12

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

2

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 / 4;

\

Which character signifies the beginning of an escape sequence?

char

Which data type typically requires only one byte of storage?

\r

Which escape sequence causes the cursor to move to the beginning of the current line?

False

The C++ language requires that you give variables names that indicate what the variables are used for.

string

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

single, double

The float data type is considered _____ precision, and the double data type is considered _______ precision.

True

A preprocessor directive does not require a semicolon at the end.

Preprocessor directive

A statement that starts with a # is called a

False

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

bool

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

scope

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

'single quotation marks'

Character constants in C++ are always enclosed in ______.

14

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. }

double payCheck;

Which of the following defines a double-precision floating point variable named payCheck?

Definition

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

Variables

_____________ represent storage locations in the computer's memory.


Ensembles d'études connexes

Chapter 4 - An Introduction to Stakeholder Analysis

View Set

Chapter 1: Using Technology to Change the World

View Set

Chapter 7 - Organizational Culture

View Set

Complete the sentences. Put the verbs in the past simple and past perfect. We <didn't get> a table in the restaurant because we <hadn't booked>. (not get, not book)

View Set