C++ Early Objects, Ninth Edition - Chapter 2

Ace your homework & exams now with Quizwiz!

Of the following, which is a valid C++ identifier? A) June1997 B) _employee_number C) _department D) myExtraLongVariableName E) All of the above are valid identifiers

E) All of the above are valid identifiers

What is the value of cookies after the execution of the following statements? int number = 38, children = 4, cookies; cookies = number % children; A) 2 B) 0 C) 9 D) .5

A) 2

These are data items whose values do not change while the program is running. A) Literals B) Variables C) Comments D) Integers

A) Literals

What will the value of x be after the following statements execute? int x; x = 18.0 / 4; A) 4.5 B) 4 C) 0 D) unknown

B) 4

This is used to mark the end of a complete C++ programming statement. A) Pound Sign B) Semicolon C) Data type D) Void

B) Semicolon

In a C++ program, two slash marks ( // ) indicate: A) The end of a statement B) The beginning of a comment C) The end of theprogram D) The beginning of a block of code

B) The beginning of a comment

________ represent storage locations in the computer's memory. A) Literals B) Variables C) Comments D) Integers

B) Variables

Every complete C++ program must have a ________. A) comments B) function named main C) preprocessor directive D) symbolic constant E) cout statement

B) function named main

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? A) name = Jane; B) name = "Jane"; C) name = 'Jane'; D) name = (Jane);

B) name = "Jane";

Which data type typically requires only one byte of storage? A) short B) int C) float D) char E) double

D) char

A character literal is enclosed in ________ quotation marks, whereas a string literal is enclosed in ________ quotation marks. A) double, single B) triple, double C) open, closed D) single, double

D) single, double

The first step in using the string class is to #include the ________ header file. A) iostream B) cctype C) cmath D) string

D) string

If you use a C++ key word as an identifier, your program will: A) Execute with unpredictable results B) not compile C) understand the difference and run without problems D) Compile, link, but not execute E) None of the above

B) not compile

What will the value of x be after the following statements execute? int x; x = 18 % 4; A) 0.45 B) 4 C) 2 D) unknown

C) 2

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) letter = z; B) letter = "z"; C) letter = 'z'; D) letter = (z);

C) letter = 'z';

The float data type is considered ________ precision, and the double data type is considered ________ precision. A) single, double B) float, double C) integer, double D) short, long

A) single, double

Which one of the following would be an illegal variable name? A) dayOfWeek B) 3dGraph C) _employee_num D) June 1997 E) itemsorderedforthemonth

B) 3dGraph

You must have a ________ for every variable you intend to use in a program. A) purpose B) definition C) comments D) constant

B) definition

Which of the following defines a double-precision floating point variable named payCheck? A) float payCheck; B) double payCheck; C) payCheck double; D) Double payCheck;

B) double payCheck;

A variable's ________ is the part of the program that has access to the variable. A) datatype B) value C) scope D) reach E) None of the above

C) scope


Related study sets

STUDY EXAM 2 - Quizzes/Study Guide

View Set