Tuesday, 28 November 2017

C Programming Tokens

  • C Programming Tokens are the smallest individual parts of a Program.

Types of Token:

  1. Keyword
  2. Identifiers
  3. Constants
  4. Strings
  5. Special Symbol
  6. Operators

1. Keyword:

  • Keywords are the reserve words having a fixed meaning given by the compiler.
  • We have to use the keywords in lower case letter.
    • Ex: void, for, else, if, struct, class, while, do, union etc.

2. Identifiers:

  • Identifiers used to identify the variables, functions, pointers and some user-defined datatypes.
  • Rules for Identifiers:
    1. The name of an Identifier always starts with an alphabet or underscore ( _ ).
    2. It must not be a keyword.
    3. There mustn't have any space in between any alphabets.
    4. Identifiers are case sensitive.
    5. Punctuation and special characters aren’t allowed except underscore.
    6. It may be the combination of alphabets and digits, but the 1st letter must be an alphabet. 

3. Constants:

  • C constants are like normal variables, but only difference is their value can't be modified by the program once defined.
  • Constants have the fixed values.
  • The constants are also called as Literals.
  • Constants may belonging to any of the datatypes.

4. Strings:

  • Strings are the collection of characters.
  • These are written in double quoted form only.
    • Ex: "Hello"
  • Always the strings are teminated with a null charachter.

5. Special Symbols:

  • The spcial symbols are used in a C Program to define some cases like beginning, termination etc.
    • Ex: 
      • Curle braces - {} 
      • Parenthesis - ()
      • Semicolon - ;
      • Comma - ,
      • Colon - :

6. Operators:

  • Operator are the symbols which are used to perform logical and mathematical operations in a Program.
    • Ex: +, -, *, /, %, =, ++, --, ==, += etc.