Free Online Flashcard Deck

02 Variables, Types, and Operators Free Online FlashCards

Study 02 Variables, Types, and Operators with 12 free online flashcards. Review key terms, definitions, and concepts with this interactive flashcard deck.

12 cards
01
Front

What does a C++ type determine?

Back

A type determines which values an object or expression can represent and which operations are valid.

02
Front

What is the typical difference between `int` and `double`?

Back

`int` represents whole numbers, while `double` represents floating-point numbers with fractional parts.

03
Front

Why initialize a local variable before reading it?

Back

A variable should be initialized before it is read; an uninitialized local built-in variable does not have a useful automatic value.

04
Front

What safety benefit does brace initialization provide?

Back

Brace initialization rejects many narrowing conversions, such as assigning `3.14` to an `int`.

05
Front

What restriction does `const` place on a variable?

Back

A `const` variable cannot be modified after initialization and must be initialized when declared.

06
Front

How does `constexpr` differ from `const`?

Back

Every `constexpr` variable is constant and is intended for constant expressions; a `const` variable is not necessarily a compile-time constant.

07
Front

What is a name's scope?

Back

Scope is the region of a program in which a name can be used.

08
Front

What happens when an inner name shadows an outer name?

Back

An inner declaration with the same spelling hides the declaration from the outer scope within the inner region.

09
Front

Which cast makes an intentional numeric conversion explicit?

Back

`static_cast` is the preferred general-purpose C++ cast for a well-understood numeric conversion.

10
Front

How does integer division differ from floating-point division?

Back

For integer operands, division discards the fractional part: `7 / 2` produces `3`, while `7.0 / 2` produces `3.5`.

11
Front

How do prefix and postfix increment differ?

Back

For `++x`, the variable is incremented before the expression's value is used; for `x++`, its old value is used first.

12
Front

What is the difference between `==` and `=`?

Back

`==` compares two values for equality, whereas `=` assigns a value to an existing modifiable object.