Tokens in C Flashcards
What are the types of tokens in C?
CSIOKS:
Constants String literal Identifiers Operators Keywords Separators
Constants can also be called as?
Literals
What are the types of constants?
Numeric constants
Character constants
What are the types of a numeric constant?
- Integers
2. Floating - point numbers
What are the rules for defining a numeric constant?
No commas
No spaces between the unary sign (+ and -) and the digits
Must begin and end with a digit
What is a character constant?
A single letter or number enclosed with single quotations
Define the escape character: '\n' '\a' '\b' '\t' '\0' '\'' '\"' %%
Newline alert backspace tab null single quotes double quotes percent symbol
What is a string literal?
A sentence or lines of texts enclosed with double quotations
What are identifiers?
Descriptive names given to variables and constants
What is a variable?
They store literals and can be changed during the execution of the program
What are the rules on creating an identifier?
- It must consist of letters, numbers, and underscores
- Cannot begin with a digit
- An identifier defined in the C library is invalid
- They are case sensitive
What are operators?
Math symbols in C
Operators follow a hierarchy like pemdas. Label the arithmetic expressions from highest to lowest and evaluate its associativity:
- Addition and subtraction
- Parenthesis
- Unary signs (Positive and negative signs)
- Multiplication, division, and modulo
Parenthesis - left to right
Unary signs (Positive and negative signs) - right to left
Multiplication, division, and modulo - left to right
Addition and subtraction - left to right
What do you call a statement that stores a computation result and perform arithmetic operations in a program?
Arithmetic operators
What is a keyword and a reserve word?
Keywords are reserved by the language and has a meaning to the compiler.
Reserved words are for special use and cannot be used as an identifier.