C++ Deck 3 Flashcards

1
Q

What is the associativity of:
?:
(Conditional)

A

Right-to-left

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the associativity of:
= , += , -= , *= , /= , «= ,&raquo_space;= , %= , &= , ^= , |=
(Assignment)

A

Right-to-left

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the associativity of:
,
(Comma)

A

Left-to-right

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the precedence level of a combined assignment operator?
i.e. += , -=, *=, etc.

A

The operator drops precedence to be equivalent to the precedence level of any other assignment operator regardless of the original precedence of its associated arithmetic operator.

=+ has the same precedence as =* for example.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What does this expression do: +=

A

variable = variable + expression

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What does this expression do: -=

A

variable = variable - expression

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What does this expression do: *=

A

variable = variable * expression

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What does this expression do: /=

A

variable = variable / expression

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What does this expression do: %=

A

variable = variable % expression

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Are combined assignment operators (-=, *=, %=, etc.) Unary, Binary, or Ternary?

A

Binary. The variable is the L-value operand and the expression is the R-value operand.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Can the %= operator be used for float-point (aka double) values?

A

No. Just like the normal % (modulus), it can only be used for integer values.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

When automatic conversion of data types occurs in C++, what is the general rule of thumb for ordering the types from smallest to largest without data loss?

A

char < short < int < long < float < double < long double

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

A compile time operation to explicitly change the type of a value from its current type to the target type.

A

static_cast

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

A conditional statement that allows you to execute a block of code based on a specified condition.

A

if statement

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

A statement that provides an efficient way to select one of many code blocks to execute based on the value of a variable or an expression. It compares the value against different cases and executes the code block associated with the matching case.

A

switch statement

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

A ternary operator that can evaluate a simple if/else statement.

A

conditional operator

17
Q

The specification of the order in which the individual statements, instructions or function calls of an imperative program are executed or evaluated.

A

control flow

18
Q

The default control flow type in which statements are executed line by line.

A

sequential

19
Q

Control flow types used for decisions; branching – choosing between two or more alternative paths.

A

Selection
(if, if/else, switch, conditional statements)

20
Q

Control flow type used for looping – repeating a piece of code multiple times in a row.

A

Repetition
(while, do/while, for)

21
Q

True or False: Any C++ expression that evaluates to a value (i.e. any R-value) can be interpreted as a true/false condition.

A

True

22
Q

The meaning of this comparative operator: ==

A

equals

23
Q

The meaning of this comparative operator: !=

A

is NOT equal

24
Q

The meaning of this comparative operator: <

A

less than

25
Q

The meaning of this comparative operator: <=

A

Less than or equal to