This document discusses the five main types of tokens in C++ - keywords, variables, constants, strings, and operators. It provides definitions and examples of each token type. Keywords are reserved words that cannot be used as variable names, while variables store values that can change. Constants represent fixed values, strings group characters within double quotes, and operators perform actions on operands like arithmetic, comparison, and assignment.
2. Tokens are the basic building blocks in C++ language.
The smallest individual units in a program are known as
tokens.
A program is constructed using a combination of these
tokens.
TOKENS
5. Definition:
Sequence of characters that have a fixed
meaning.
Keywords must be written in lower
case.
Reserved identifiers and can’t be used
as names for the
program variables
user-defined program elements.
KEY WORDS
Examples:
int, float, char,
double, switch,
break, char, const,
Continue, default,
for, if, goto, static,
void, sizeof, while,
return, int, long, do,
while etc…
7. Definition:
A variable is a quantity
whose value may
change during the
program execution.
Examples:
int a, char choice, etc.,
VARIABLES
Variables in
C++
Numeric
Variables
To store either integer
values or floating
point values
Character
Variables
Alphabets and
numbers from 0-9
inserted between
single quotes
8. Naming Conventions:
A variable name should
• contain alphabets (a-z , A-Z) and digits (0-9).
• not start with a number or a digit.
• not be a keyword.
• case sensitive.
9. Naming Conventions:
A variable name should
• contain alphabets (a-z , A-Z) and digits (0-9).
• not start with a number or a digit.
• not be a keyword.
• case sensitive.
13. Definition:
A group of characters that are treated as a single data
item enclosed in double quotes are known as strings.
General syntax:
• char string-name[size];
• size determines the number of characters in the string
name.
Example: char city[9]=“New York”;
STRINGS
15. Definition:
An operator is a symbol that performs
operations on one or more operants.
There are 8 types of operators supported by C++
language.
OPERATORS