v C Tokens:-“It
is a shortest unit of a program.”
(1)Keywords:- It is those words whose meaning has already been known to the compiler. That is meaning to each keyword is fixed. All keyword written in small case letters.
Examples:- auto, break, extern, char, const, double, else, enum, float, int , return, struct, void, union, while etc.
Types
of Tokens:-
(2)Identifiers:
Rules
for writing identifiers
Ø First
letter must be an alphabet or underscore.
Ø From
second character onwards any combination of digits, alphabets, or underscore is
allowed.
Ø Only
digits , alphabets , underscore are allowed. No other symbol is allowed.
Ø Keywords
cannot be allowed as identifiers.
Ø For
ANSI C max. length of identifiers is32.
Examples:-
Valid Identifiers
|
Non Valid Identifiers
|
Order-no
name
-err
-246
abc_xyz123
|
x_$
big value
order-no
Sname
Abc + 123
int
|
v C Constants:-
It refers the fixed value that don’t change during the execution of a program.
They are also known as literals.
Types
of C constants:-
v Numeric Constants:-
(1)Integer
constants:- These are three types.
Ø Decimal Constants:-“Sequence
of digits 0 to 9 without fractional port”.
Ø Octal Constants:-“They
have sequence of number from 0 to 7 and first digit must be zero.”
Ø Hexadecimal Constants:-“They
have sequence of 0 to 9 and A to F (represent 10 to 15).”
(2)Real Constants:-
They are number with fractional part that is number with decimal point.
Examples:- 10.70, 0.78, 0.45F.
Types of Real constants:-
(a)Float.
(b)Double
v Non-Numeric Constants:-
(1)Single Character Constants:-They
are enclosed in single quotes. They
consist of single character or digit.
Examples:-
‘4’, ‘A’, ’\n’
(2)String
Constants:-They are sequences of characters,
digits, or any symbol enclosed in double quotes.
Examples:-
“hello” , “24twenty four” , “$^ABCE” ,
”123.23”
Backslash
Constant:- These are some backslash constants
\b -----For back space
\f------ For form feed
\n----- For newline
\r----- For carriage return
\”----- For double quotes
\0----- For null
|
\’ -----For single quotes
\?-----For question mark
\a-----For alert
\t------For horizontal tab
\v-----For vertical tab
|
Ø Backslash
constant are also known as White Space Characters.
Ø The
printf function is used for recognizes all White Space Characters.
Comments are treated
as White Space Characters by C compilers.
Operators:- “An
operator denotes an operation to be performed on some data that generates some value”.
For
Example :- Plus
operator (+) on 2 and 6 generates 8.Here
2 and 6 are operands.
C is very rich in built-in operators. There are four
types of operators.
(a)
Arithmetic.
(b)
Relational.
(c)
Logical.
(d)
Bitwise.
Read More:-Click Here
No comments:
Post a Comment