Tuesday, 30 July 2013

What are Tokens in c language?

Tokens:-
                  Tokens are the smallest individual unit of any language . It is the smallest element in the 'C' language .

Tokens are :-
  1. Constant
  2. Keyword
  3. Identifiers
  4. Punctuation
  5. Operators
1. Constant :- A constant value is the one which does not change during the execution of a program
  Types of constant:-
  1.  Integer Constant
  2. Real Constant
  3. Character Constant
  4. String constant

2. Keyword :- The word which have special meaning to the compiler is called keyword. The meaning of keyword can't be changed. They are also called reserved word . Keyword can't be used as a variable name . They are 32 keywords in 'C' . All keyword are in lower case .
List of keywords

  1. auto                           
  2. break 
  3. case
  4. char
  5. const
  6. continue
  7. default
  8. do
  9. double
  10. else
  11. enum
  12. extern
  13. float
  14. for
  15. goto
  16. if
  17. int
  18. long
  19. register
  20. return
  21. short
  22. signed
  23. size of
  24. static
  25. struct
  26. switch
  27. typed ef
  28. union
  29. unsigned
  30. void 
  31. volatile
  32. while
3.Identifiers/ Names
Identifiers is the name of user-defined variable, array and functions .
'C' is a case-sensitive language that is upper case and lower case alphabets are different for 'C'.
  Ex- 'Num' and 'num' are two different identifiers for c language.
Rules of identifiers :-
  • First character must be an alphabet or underscore.
  • Identifiers name must consist of only letters, digits and underscore.
  • An Identifier should have less than 31 characters.
  • The keyword can not be used as identifiers.
  • No comma or blank are allowed with in an identifier.

4.Punctuations:-
Semicolons,colons,commas,apostrophes,quotations mark,braces,brackets and parentheses .
 ; : , ' " () {} [] * = # .

5. Operators :-
  • Assignment Operator
  • Arithmetic Operator
  • Relational Operator
  • Logical Operator
  • Increment Operator
  • Decrement Operator
  • Boolean Operator
  • Bit-wise Operator
  • Size of() Operator
  • Comma Operator


No comments:

Post a Comment