01 Tokens
01 Tokens
Identifier
Tokens Literals
String
Operator
32 keywords in C
50 Keywords in java
Small case
int signed if
break auto
else volatile
unsigned
short
switch
enum continue extern
long case
void sizeof
float default
struct goto static
while
double union for const
char return register
typedef do
Array name
Function name
Etc.
emp_name
Float
float X
int_float
By: Dr. Prakash Singh
Tanwar
Rules for Identifier names
3. First character of identifier name
must be an alphabet or
underscore(_)
1emp X
Emp_name
_emp1
emp name X
Non
Numeric
Numeric
Without Point
Ex.
• 54
• 234
By: Dr. Prakash Singh
Tanwar
Literals
Integer Literals
There are three type of integer Literals
i. Decimal
ii. Octal
iii. Hexadecimal
Symbol (+ & -)
Alphabets (u, U, l, L)
• 123 0 +123 -123
• 123456l 1,256 X 1 234 X $256 X
• 15ORs X 1245U
Digits : 0 to 7
Symbol : + and –
Alphabets : u, U, l, L
$0583 X 05673 06 73 X
5_673 X
Digits : 0 to 9
Alphabets : A to F , a to f , x, X
Symbol : + and –
U, u , l, L at and as suffix
By: Dr. Prakash Singh
Tanwar
Hexadecimal integer Literals
Integer Literals
0xAUB X
By: Dr. Prakash Singh
Tanwar
Literals
Rules for Integer Literals
Digits, +, -, are allowed
• 12345678L
• 12345U
Ex.
• 3.4 5.231 53. .42
• 0.32 1,234.4 X 1234Rs X
• $123.5 X 123 54.2 X 3.2X103 X
Character Literals
Character
Literals
Single Backslash Trigraph
character character character
Literals Literals Literal
Ex :
• ‘A’ ‘a’ ‘@’ ‘1’
‘\\’ :- \
(Rarely used)
‘???’ : ?
‘??’’ : ’
‘??”’ : “
Ex Result
• “Hello PST” Hello PST
• “Hello PST, How are you?” Hello PST, How are you?
ew
• “old\\new” old\new
• “mango\banana” manganana
• “mango\\banana” mango\banana
By
Distinct
Distinct
Identical
Distinct
Distinct
Distinct
X
X
X
X
X
X