Sunday, 28 August 2011

Qu 18. what is token in c? Explain all type of tokens avalible in C

 In a C source program, the basic element recognized by the compiler is the "token." A token is source-program text that the compiler does not break down into component elements.

Syntax

token:
    keyword

identifier constant string-literal operator punctuator

The keywords, identifiers, constants, string literals, and operators described in this section are examples of tokens. Punctuation characters such as brackets ([ ]), braces ({ }), parentheses ( ( ) ), and commas (,) are also tokens.


C token is an individual word present in the c-language. There are 6 types
  • Keywords: keywords are defined by the software with the specified meaning. 
  • In c language 32 keywords are there
                          Example: double,int,struct, etc
  • Identifiers:User defined variable names.
  • Constants: The value which is not changed during the execution
  • Strings: Group of caharacters enclosed in " "
  • Operators: The following are the operators available in c
  • 1.Arthematic Operators: [+,-,*,/,%] 
    2.Assignment Operators: [=] 
    3.Relational Operators: [<,<=,>,>=,==,!=] 
    4.Logical Operators: [and,or,not] 
    5.increment/decrement Operators:[++,--] 
    6.Bitwise Operators: [&,|,~,^,>>,<<] 
    7.Conditional or terinary Operator:[?:]
  • Special characters: ,(comma) -to seperate 
  • 2 variables sizeof Operators -returns the size of the variable

1 comment: