Search This Blog


Friday, September 13, 2019

Tokens of C language

Tokens:-

 Tokens are the smallest unit,which are used to create a program in any programming language.

There are some tokens in C:-

  1. Character set
  2.  Constant
  3. Variable
  4. Operator
  5. Data type
  6. Keywords
  7. Escape sequence
  8. Format specifier/type specifier
  9. Identifier
  10. Comment
  11. Delimeter
  12. Expressions

 ➤ Character set:-

 It represents different types of character, that are categorized into three parts.
  • Alphabet (A-Z) or ( a-z)
  • Digit (0-9)
  • Special character (@,$,%, etc)

➤Constant:-


  •  It is a fixed value which cannot be changed during execution of program. 
  •  It is also known as literal.

It can be divided into three parts :

types of constant,types of constant in C
types of Constant

  ⏩ Character Constant :

      It represents only single character that must be enclosed within single cot.
       eg:- 'A' , '6' , 'm' , '$' , etc.

  ⏩ String Constant :

  • It is a group of zero, one or more characters which are enclosed within double cot.
  • It must be terminated with null character (\0).
  • Null character represents ending of character in string.
  eg:- "coc" ⇒ c o c \0  (written inside it ⃢⃢⃢⃢)
          "1"    ⇒ 1 \0  (written inside it ⃣⃣)
                                 
       ⤔here "\0" denotes end of the character

➤ Variables :-

 Variables is a storage/memory location which is used to store constant value according to             requirement.
The value of variable can be changed during execution of program.
   eg:-
           a  = 10                                  
                      b  = 10.5
                name  = "xyz"
                    ch   = 'A'
    ➳here:- a,b,name and ch are variables. 

There are two types of variable:-

  • Local Variable
  • Global Variable

 ⏩ Local Variable:-

  • This type of variable must be declared within any particular function.
  • It provides local accessibility.
  • It means , these variable can not be accessed outside function.

 ⏩  Global Variable:-

  • These variables must be declared outside function.
  • It can be accessed outside function.
  • We can say that it provides global accessibility.   

 ‎

No comments:

Post a Comment