Hogan Chapter 2

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

This operator in C++ allows you to identify how many bytes of storage on your computer system an integer data value requires. len bytes f(x) int sizeof

sizeof

The _____ causes the contents of another file to be inserted into a program. Backslash Pound sign Semicolon #include directive

#include directive

Which operator returns the remainder in integer division? + * & % ||

%

Character constants in C++ are always enclosed in ______. [brackets] "double quotation marks" 'single quotation marks' {braces} (parentheses)

'single quotation marks'

What will the following code display? int x = 0, y = 1, z = 2; cout << x << y << z << endl; ____________________________________________________ 0 1 2 0, 1, and 2 on separate lines Xyz 012

0 1 2

Assuming you are using a system with 1-byte characters, how many bytes of memory will the following string literal occupy? "William" ___________________________________________ 7 14 8 1

8

What will the following code display? cout << "Four\n" << "score\n"; cout << "and" << "\nseven"; cout << "\nyears" << " ago" << endl; 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

A

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

False

Besides decimal, two other number systems you might encounter in C++ programs are: Octal and Fractal Hexadecimal and Octal Unary and Quaternary Base 7 and Base 9

Hexadecimal and Octal

These are data items whose values do not change while the program is running. Literals Variables Comments Integers

Literals

In memory, C++ automatically places a ___________ at the end of string literals. Semicolon Quotation marks Null terminator Newline escape sequence

Null terminator

A statement that starts with a # is called a: Comment Function Preprocessor directive Keyword

Preprocessor directive

This is used to mark the end of a complete C++ programming statement. Pound Sign Semi Colon Data Type Void

Semi Colon

In programming terms, a group of characters inside a set of quotation marks is called a: String Literal Variable Operation Statement

String Literal

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

The beginning of a comment

____________ must be included in any program that uses the cout object. Opening and closing braces The header file iostream Comments Escape sequences

The header file iostream

_____________ represent storage locations in the computer's memory. Literals Variables Comments Integers

Variables

Which character signifies the beginning of an escape sequence? // / \ # {

\

This control sequence is used to skip over to the next horizontal tab stop. \n \h \t \a \'

\t

Which data type typically requires only one byte of memory? short int float char double

char

The ______ is/are used to display information on the computer's screen. Opening and closing braces Opening and closing quotation marks cout object Backslash

cout object

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

double payCheck;

Every complete C++ program must have a _____________. comment function named main preprocessor directive symbolic constant cout statement

function named main

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

single, double

The float data type is considered _____ precision, and the double data type is considered _______ precision. single, double float, double integer, double short, long

single, double

Given the following program: 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) of the program causes the output to be displayed to the screen? 13 and 14 8 and 9 14 13 15

14

Assume the following variables have been declared in your program: int number = 38, children = 4, cookies; After the following C++ instruction is executed: cookies = number % children; What is the value stored in cookies? ______________________________________________________ 2 0 9 .5

2

What will the value of x be after the following statements execute? int x; x = 18 % 4; -------------------------------------------------------------------------- 0.45 4 2 No answer text provide

2

Which of the following would be an illegal variable name? dayOfWeek 3dGraph _employee_num June1997 itemsorderedforthemonth

3dGraph

What will the value of x be after the following statements execute? int x; x = 18 / 4; ____________________________________ 4.5 4 0 No answer text provided.

4

Of the following, which is a valid C++ identifier? June1997 _employee_number ___department myExtraLongVariableName All of the above are valid identifiers.

All of the above are valid identifiers.

What will the following code display? cout << "Four " << "score "; cout << "and " << "seven/n"; cout << "years" << "ago" << endl; A. Four score and seven yearsago B. Four score and seven years ago C. Four score and seven/nyearsago D. Four score and seven yearsago

C

What will the following code display? cout << "Four" << "score"; cout << "and" << "seven"; cout << "years" << "ago" << endl; ____________________________________________ A. Four score and seven years ago C. Fourscoreandsevenyearsago B. Four score and seven years ago D. Fourscore andseven yearsago

C

For every opening brace in a C++ program, there must be a: String literal Function Variable Closing brace

Closing brace

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

True

When typing your source code into the computer, you must be careful since most of your C++ instructions, header files, and variable names are case sensitive. True False

True

You must have a ___________ for every variable you intend to use in a program. purpose definition comment constant

definition

The numeric data types in C++ can be broken into two general categories: numeric and character singles and doubles integer and floating point real and unreal

integer and floating point

Assume that a program has the following string object definition: string name; Which of the following statements correctly assigns the string literal Jane to the string object? name = Jane name = "Jane" name = 'Jane' name = (Jane)

name = "Jane"

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

not compile


संबंधित स्टडी सेट्स

Day 1 Key Vocabulary and Concepts

View Set

Management of Information Security Chapter 1

View Set

Psych Exam 1 - Ch. 27 (Anger, Aggression, & Violence)

View Set

Engelska oregelbundna verb- från choose till do

View Set

2 - Project Scope Management - Test

View Set