C++ Deck 1 Flashcards
What is the definition of lexical elements in C++?
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.
What are keywords?
Particular words that have a definitive meaning and purpose in C++, e.g. - namespace
aka “Reserved Words”
What are directives?
Specific instructions given to the C++ compiler to perform actions like including libraries, defining constants, etc. e.g. - #include
What are identifiers?
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)
What are literals?
Values directly specified in the program, e.g. - 10, 25, etc. sometimes referred to as “hardcoded”
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.
Variable
True or False: An operator is a lexical element.
True
What are the operation, operator, and operand in this statement: x + y
operation: addition
operator: +
operands: x, y
What are the operation, operator, and operand in this statement: 15 - 12
operation: subtraction
operator: -
operands: 15, 12
What are the operation, operator, and operand in this statement: z * 9
operation: multiplication
operator: *
operands: z, 9
What is an arity in C++?
The number of arguments or operands taken by a function, operation, or relation.
What is a Unary operator?
An operator that uses exactly 1 operand.
What is a Binary Operator?
Operators that take 2 operands (even if that’s not obvious at first glance.)
The most common arity for C++ operators.
What are Ternary Operators?
These operators use exactly 3 operands. The conditional operator (?:) and the spaceship operator (<=>) are examples. Not covered in-depth during these chapters.
Is -20 Unary, Binary or Ternary?
Unary
There is only one operand (20) and the operator is the negative sign (also known as unary minus)