CHAPTER 5
Introduction to Programming
Character set
• The set of valid characters of C++ Language. It consists of letters, digits, special characters,
white spaces
Tokens
• Fundamental building blocks of C++ program. (Lexical units)
Classification of Tokens
• Keyword (Reserved word): They convey a specific meaning to the compiler.
Eg: float, if, break, switch
• Identifiers: Names given to different program elements.
(a) Variable: Name given to memory location.
(b) Label: Name given to a statement.
(b) Function name: Name given to a group of statements.
Rules to form an identifier:
• Identifier is a sequence of letters , digits and underscore.
• The first character must be letter or underscore
• Keywords cannot be used as identifiers.
• Special characters or white spaces cannot be used
Eg: score, score1, score_1, INT
• Literals(Constants): Constant values used in program.
(a) Integer literals: Whole numbers. Eg: 23, -145
(b) Floating literals: Constants having fractional parts.
Eg: 12.5, 1.87E05
(c) Character literals: A character in single quotes. Eg: ‘a’, ‘8’
Escape sequences are character constants
used to represent non graphic symbols. Eg: ‘\n’ , ‘\t’ etc
(d) String literals: One or more characters within double
quotes. Eg: “a”, “score1”
• Operators: Symbols that indicate an operation. Eg: +, <, *, &&
• Punctuators: Special symbols used in C++ program. Eg: # ; ( ] }