Sei sulla pagina 1di 11

Tokens

Tokens
DEFINITION: The smallest individual unit in a program is
called as “token”.
C++ tokens
 Keywords – Words reserved for use by the language.eg.
Enum,Delete,Friend.
 Identifiers – Identifiers refers to the name used to identify
variables,functions, classes ,arrays. Eg int x, class student
 Constants – A value declared as constant cannot be
manipulated.
Eg. Const int size =10
Char name (size) ;
 Strings - is nothing but an array of characters.
Operators
Defn.Operators are symbols used in C++ to perform a certain
activity.
Operator types
 << Insertion operator
 >> Extraction operator
 :: Scope resolution operator
 ::* Pointer-to-member declarator
 ->* Pointer-to-member operator
 .* Pointer-to-member operator
Delete Memory release operator
Endl Line feed operator
New Memory allocation operator
Setw Field width operator
Hierarchy of C ++ data types
C++ Data types

Built-in type
User-defined type Derived type
Structure
Union array
class function
enumeration pointer

Integral type Void Floating type

int char float double


Basic control structures
Entry Entry Entry

Action 1 Condition
loop

True
Action 1 Action 2 Condition Action 1
Action 2
False
Exit
Action 2
Action 3

Action 3
(a) Sequence (b) Selection ( c ) Loop
C++ statements to implement control
structures

Control structures

Selection Sequence Loop

if-else Switch Do-while while,for

Two-way branch Multiple branch Exit-control Entry-control


If statement
Form 1
if (expression is true)
{
action1;
}
action2;
action3;
Form 2
if (expression is true)
{
action1;
}
else
{
action2;
}
action3;
The switch statement
Switch (expression)
{
case1:
{
action1;
}
case2:
{
action2;
}
default:
{
action4:
}
}
action5;
The Do-while statement
do
{
action1;
}
while(condition is true);
action2;
The While statement
While (condition is true)
{
action1;
}
action2;
The for statement
for (initial value; test; increment)
{
action1;
}
action2;

Potrebbero piacerti anche