C++ Deck 2 Flashcards

1
Q

What is an R-value?

A

The value that appears on the right-side operand of an assignment (=) operator.

For example, x = y has an R-value of y.

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

What is an L-value?

A

L-values are variables that appear as the left operand for an assignment (=).

For example, x = y has an L-value of x.

At this point int he course, L-values are only storage locations.

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

Is this a valid L-value: a+b = c

A

No. L-values can only be variables, they can’t contain operators.

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

Associativity for the Assignment Operator (=)

A

right-to-left

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

Which operator has the highest precedence of all the arithmetic operators?

A
  • (Unary Minus)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the associativity of: - (unary minus)

A

Right-to-left

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

What is the associativity of +, -, *, and / arithmetic operators?

A

Left-to-right

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

When the / (division) operator is used to divide two operands which are both integer values, what will the result always be?

A

An integer. Any fractional portion of the answer is discarded/truncated (and NOT rounded).

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

True or False: The % (modulus) operator can be used and compiled in a program for non-integers.

A

False.

It must only be used for integers. Floating-point values with a modulus operator will not compile.

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

True or False: The % (modulus) operator has the same precedence as * and / operators.

A

True

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

What is the associativity of the % (modulus) operator?

A

Left-to-right

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

What is the operator precedence order among all arithmetic operators from highest to lowest?

A
  1. Parentheses and Unary Minus
  2. Multiplicative: *, /, %
  3. Additive: +, -
  4. Operators on the same level associate left to right.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the associativity of :: (Primary Scope Resolution)

A

left-to-right

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

What is the associativity of:
(), [], . , ->, dynamic_cast, typeid
(Primary)

A

left to right

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

What is the associativity of:
.* , ->*
(C++ Pointer to Member)

A

left-to-right

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

What is the associativity of:
* , / , %
(Multiplicative)

A

Left-to-right

17
Q

What is the associativity of:
+ , -
(Additive)

A

Left-to-right

18
Q

What is the associativity of:
&laquo_space;,&raquo_space;
(Bitwise Shift, not to be confused with insertion or extraction)

A

Left-to-right

19
Q

What is the associativity of:
< , > , <= , >=
(Relational)

A

Left-to-right

20
Q

What is the associativity of:
== , !=
(Equality)

A

Left-to-right

21
Q

What is the associativity of:
&
(Bitwise AND)

A

Left-to-right

22
Q

What is the associativity of:

(Bitwise Exclusive OR)

A

Left-to-right

23
Q

What is the associativity of:
|
(Bitwise Inclusive OR)

A

Left-to-right

24
Q

What is the associativity of:
&&
(Logical AND)

A

Left-to-right

25
Q

What is the associativity of:
||
(Logical OR)

A

Left-to-right