Tokens in C Keywords Identifiers
Tokens in C Keywords Identifiers
Tokens in
in C
C
Keywords
These are reserved words of the C language. For example int,
float, if, else, for, while etc.
Identifiers
An Identifier is a sequence of letters and digits, but must start with a
letter. Underscore ( _ ) is treated as a letter. Identifiers are case sensitive.
Identifiers are used to name variables, functions etc.
Valid: Root, _getchar, __sin, x1, x2, x3, x_1, If
Invalid: 324, short, price$, My Name
Constants
Constants like 13, ‘a’, 1.3e-5 etc.
Operators
Arithmetic operators like +, -, *, / ,% etc.
Logical operators like ||, &&, ! etc. and so on.
White Spaces
Spaces, new lines, tabs, comments ( A sequence of characters enclosed
in /* and */ ) etc. These are used to separate the adjacent identifiers,
kewords and constants.
Example
Suppose an integer is represented by a byte (8 bits). Leftmost bit is sign
bit. If the sign bit is 0, the number is treated as positive.
Bit pattern 01001011 = 75 (decimal).
The largest positive number is 01111111 = 27 – 1 = 127.
Negative numbers are stored as two’s complement or as one’s
complement.
-75 = 10110100 (one’s complement).
-75 = 10110101 (two’s complement).
printf(
printf( “Area
“Area == %f\n”
%f\n” ,, area
area );
);
printf( “Peri = %f\n” , peri
printf( “Peri = %f\n” , peri ); );
}}
else
else
printf(
printf( “Negative
“Negative radius\n”);
radius\n”);
printf(
printf( “Area
“Area == %f\n”
%f\n” ,, area
area );
);
}}