C++ Deck 1 Flashcards

1
Q

What is the definition of lexical elements in C++?

A

Words, names, symbols, etc. that are part of the lexicon of the programming language. They’re the items that a program can understand as a part of a valid statement.

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

What are keywords?

A

Particular words that have a definitive meaning and purpose in C++, e.g. - namespace
aka “Reserved Words”

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

What are directives?

A

Specific instructions given to the C++ compiler to perform actions like including libraries, defining constants, etc. e.g. - #include

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

What are identifiers?

A

Names given by the programmer to programmatic or storage elements to make our task easier, e.g. - “number” (or some other variable or function name)

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

What are literals?

A

Values directly specified in the program, e.g. - 10, 25, etc. sometimes referred to as “hardcoded”

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

A location in memory associated with a name that can store ONE value. It also has a data type that specifies what type of information it can store and how it is formatted in memory.

A

Variable

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

True or False: An operator is a lexical element.

A

True

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

What are the operation, operator, and operand in this statement: x + y

A

operation: addition
operator: +
operands: x, y

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

What are the operation, operator, and operand in this statement: 15 - 12

A

operation: subtraction
operator: -
operands: 15, 12

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

What are the operation, operator, and operand in this statement: z * 9

A

operation: multiplication
operator: *
operands: z, 9

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

What is an arity in C++?

A

The number of arguments or operands taken by a function, operation, or relation.

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

What is a Unary operator?

A

An operator that uses exactly 1 operand.

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

What is a Binary Operator?

A

Operators that take 2 operands (even if that’s not obvious at first glance.)
The most common arity for C++ operators.

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

What are Ternary Operators?

A

These operators use exactly 3 operands. The conditional operator (?:) and the spaceship operator (<=>) are examples. Not covered in-depth during these chapters.

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

Is -20 Unary, Binary or Ternary?

A

Unary
There is only one operand (20) and the operator is the negative sign (also known as unary minus)

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

Is ++ a Unary, Binary, or Ternary operator?

A

Unary. It increments the value of whatever it pre- or -post increments.

17
Q

Is “value + number” Unary, Binary, or Ternary?

A

Binary. There are two operands (value, number)

18
Q

Is X = 51 Unary, Binary, or Ternary?

A

Binary. There are two operands (x, 51)

19
Q

Is cout«num Unary, Binary, or Ternary?

A

Binary. There are two operands (cout, num)

20
Q

What is the arity of the&raquo_space; (extraction) operator used in a cin statement?

A

Binary. It uses two operands (the input, then the variable where the input is subsequently stored)

21
Q

What is cascading?

A

When an operator appears several times in the same statement, i.e. cout«x«y«z (outputs all 3 values in the order they appear from left to right)

22
Q

What is operator precedence?

A

The order in which C++ evaluates operators in a given statement containing multiple operators.

23
Q

What is left and right associativity?

A

When two operators have the same precedence, their associativity determines which order they will be evaluated in.

Left associativity is evaluated from left-to-right, Right associativity is evaluated from right-to-left.

24
Q

What is the name of this operator: =

A

Assignment Operator

25
Q

What is the assignment operator used for?

A

Assigning a value to a variable.