Chapter 2: Introduction to C++

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

B

Every C++ program must have a A) cout statement B) function main C) #include statement D) All of the above

C

Every complete statement ends with a A) period B) # symbol C) semicolon D) ending brace

1, 2, 3

How many operands does each of the following types of operators require? _____ Unary _____ Binary _____ Ternary

double temp, weight, age;

How may the double variables temp, weight, and age be defined in one statement?

int months = 2, days, years = 3;

How may the int variables months, days, and years be defined in one statement, with months initialized to 2 and years initialized to 3?

multi-line

Is the following comment written using single-line or multi-line comment symbols? /* This program was written by M. A. Codewriter */

single-line

Is the following comment written using single-line or multi-line comment symbols? // This program was written by M. A. Codewriter

A

Preprocessor directives begin with a A) # B) ! C) < D) * E) None of the above

D

The following data 72 'A' "Hello World" 2.8712 are all examples of A) Variables B) Literals of constants C) Strings D) None of the above

A

The negation operator is A) Unary B) Binary C) Ternary D) None of the above

A

When do preprocessor directives execute? A) Before the compiler compiles your program B) After the compiler compiles your program C) At the same time as the compiler complies your program D) None of the above

B, C

Which of the following are NOT valid assignment statements? (Choose all that apply.) A) total = 9; B) 72 = amount; C) profit = 129 D) letter = 'W';

B, C, D

Which of the following are NOT valid cout statements? (Choose all that apply) A) cout << "Hello World"; B) cout << "Have a nice day"\n; C) cout < value; D) cout << Programming is great fun;

C

Which of the following statements is correct? A) #include (iostream) B) #include {iostream} C) #include <iostream> D) #include [iostream] E) All of the above

T

(T/F) A left brace in a C++ program should always be followed by a right brace later in the program.

T

(T/F) A variable must be defined before it can be used.

F

(T/F) Variable names may begin with a number.

T

(T/F) Variables may be up to 31 characters long.

F

(T/F) You cannot initialize a named constant that is declared with the const modifier.

A

A group of statements, such as the contents of a function, is enclosed in A) Braces {} B) Parentheses () C) Brackets <> D) All of the above will do

C

A(n) _____ is like a variable, but its value is read-only and cannot be changed during the program's execution. A) secure variable B) uninitialized variable C) name constant D) locked variable


Ensembles d'études connexes

Bus 682 Midterm Chapters 1, 2, 3, 4, 5, 6

View Set

AP Psychology, Brain and Neurons

View Set

Chapter 2: Life Insurance Basics

View Set

N208 Exam 1 - ATI/PrepU questions

View Set

Parent-Child Nursing Set 3-2 (Chapters 23, 24, 38, and 44)

View Set

ATI- Fluid, Electrolyte and acid-base regulation, ATI Fluid, Electrolyte, and Acid-Base Regulation

View Set

Psychology 2301 - Chapter 6 Quiz Bank

View Set