Skip to main content

Tokens of C language

Tokens: Tokens are the smallest independent, individual units of C language which are of more beneficial if they remain together rather than individual.
Types of tokens:
1. Identifiers.
2. Keywords.
3. Variables.
4. Constants.
5. Puntuator.
6. Operators.

Now explanation of above these points:
Identifiers-- any programs name or any variables name.
RULES FOR ASSIGNING THE NAME OF IDENTIFIER:
1. NAME SHOULD NOT START WITH SPECIAL CHARACTERS.
2. NAME SHOULD START WITH AN ALPHABET.
3. IN BETWEEN NAME WE CAN USE SPECIAL CHARACTERS, symbols etc.
4. GAPS SHOULD NOT BI GIVEN BETWEEN THE NAME.
5. INSTEAD OF GAPS WE CAN USE UNDERSCORE.
6. DOTS ARE NOT ALLOWED IN THE NAME.
7. HE NAME IS DIVIDED INTO TWO TWO PARTS I.E. MAIN NAME AND EXTENSION NAME. THE MAIN NAME HAS A MAX. WORD LIMIT OF 8 AND EXTENSION NAME HAS A MAX. OF 3 CHARACTERS.

2. Keywords-- are the special words , reserved words or words carring special meaning in C language.

For e.g. int , char, float, long, double, auto, for, while, do, break, switch, case, class etc.
NOTE-- SINCE WE CAN'T USE KEYWORDS AS IDENTIFIERS.

For e.g. we can't use " int" as an identifier because it is a keyword, but we can use it as "Int" because C language is a " case sensitive language" which we have already discussed in my previous blog.

3. Variables-- are those whose values can be changed at any time in the program, they store our value in them before processing , they hold memory for our values , they are the named memory chunks in which value is stored.

SYNTAX--
                    data type        name.           ;
                                      Of variable
For e.g.  int  a;

They are of two types :
I. Global-- which has a tendency of changing its value throughout the whole program.
II. Local-- which has a tendency of changing its value throughout the void main only.

4. Constants or literals-- are those whose values cannot be changed during program execution.
They are of 4 types:

I) Character constant -- it include all the alphabet, characters, special symbols etc. which are written in single quotes facing toward left.
For e.g. 'a', '8', '$' etc.
II) Integer constant --it includes all the whole numbers which is a combination of numbers from 0 to 9.
III) Floating point constant-- it includes decimals or fractions.
For e.g. 9.0. , 4.8 etc.
IV) String constants-- it is a collection of characters written inside double quotes and terminated by null character('\0') and supported by data type "char" in C language.

For e.g. " sudhanshu@123"

5. Puntuators-- are the names which are given to special symbols in C language, a few of them are written bellow:

Special     Common       name in C  
Symbol.    Name.           Language.



1. #            hash.                 Pre processor
                                                Directive.

2. {}.         Curly                    delimiters.
                 Braces

3. ().          Parenthesis.          Symbol of                                                         function.

4. [].         Square braces.        Array size.

5. *           Asterick.                 Pointer.

6. &          Ampersand.           Referencing.

7. :            Colon.                      Label.

8. ;           semi colon.             Terminator.


6. Operators--
Two types of operators are :
1. Based on operands.
2. Based on operators.

                          A+ B
  Here A and B are operands and + is operator.
1. Based on operands:
  a. Uniary.
  b. Binary.
  c. Ternary.

2. Based on operators:
  a. Airthmatic operators:
         i.e. +, -, *, /.
Note: here the / gives us the qoutient.
  b. Relational operators:
       i.e. <,>,<=,>=.
  c. logical operators:
     These are used when we have more than one condition.
i.and gate(&&)
ii. Or gate(||)
iii. Not gate(!)

  d. Equality operators:
      i.e. LHS==RHS
  e. Assignment operators:
      i.e. LHS=RHS
  f. Modulus operator:
     ie. % it gives us remainder.

If you have any doubts please write it in the comments and I will try to solve it.

By sudhanshu tidyal

 

Comments

Popular posts from this blog

How nanobots are used as artificial blood?

Nanobots are actually nano-robots  , those robots whose parts are in the size of nanometers. The application of these nanobots is this that they can be used in those areas where it is difficult for human hands. Since now in human body artificial blood can be used which is made of these nanobots . Just like human blood which consist of 1. Red blood cells 2. White blood cells 3. Platelets Function of RED BLOOD CELLS 1. Haemoglobin transports about 97-98% of oxygen from lungs to body tissues as oxyhaemoglobin. 2. Haemoglobin also transports about 23% of carbon dioxide from the body tissues to the lungs as carbaminohaemoglobin. FUNCTION OF WHITE BLOOD CELLS 1. Neutrophils act as soldiers gaurding the body . They eat up invading microbes by phagocytosis.  2. Basophils secrete heparin which prevents coagulation of blood in the blood vessels. 3. Monocytes act as scavengers and eat up damaged and dead cells to keep the body clean. 4. Acidophils help in healing of...

c program for swap two numbers by two ways

We can write the c program for swap in two  ways: 1. by using only two variable, 2. by using three variable. In first we will discuss our first type program i.e. by using only two variable. in this program only two variables are used to swap two numbers, in order to write a program we need to build a logic and after that the program will run. 1.firstly try to solve this program on your own 2.after this try to understand the problem i.e. to swap two numbers 3.now build a logic between two numbers       a=1,b=2    if i write a=b & b=a this is WRONG  way. why this is wrong? A question comes in mind. This is due to the  reason that when a=b (means the value in b is assigned to a) then the value in a will vanish. Now when we wite b=a(means the value in a is assigned to b) but from the above line we came to know that the value of a is vanished and the the value which is in a is of b. so the proper way of making a relation betwee...