Skip to main content

Tokens and its types in 'C'

   Tokens are the smallest individual unit of a program or in simple words it is a main part of C program.Tokens are the building blocks of any program. The smallest individual and basic unit of a C programming is called c tokens.
  
  *    Normally there are six types of tokens in C:-

i> Keywords:-
         Keywords are special words that are used to give a special meaning to the program and can't be used as variable and constant.They are basically a sequence of characters that have fixed to mean. For example:-
                auto     double      long     break
                float    short        char     if
               while    continue   int       void etc.
All keywords must be written in lower case.It is 32 in number.


ii> Identifiers:-
        The identifiers are basically a token. It can be a variable's name or a label's name. So identifiers are actually a user defined data. But there are certain rules to frame an identifier. They are as follows:-
  *  An identifier can have alphanumeric characters and underscore. i.e A-Z , a-z , 0-9 , _ .

  *  But it should always start with an alphabet or underscore.Not with a number.

  *  It should not be a reserved keyword.

  *  identifiers are actually case sensitive in C language. So flag and FLAG are actually different.

  *  Use of special characters is forbidden.

Also avoid starting an identifier with underscore because compiler thinks that it is system defined.


iii> Variables:-
         The variables are used to give the name and allocate memory space. An entity that may vary during execution. Variables are the data item whose value may vary during the execution of the C program. A specific location or address in thre memory is associated for each variable and value of that variable is stored in that locatuion . All the variables must have their type indicated so that the compiler can recoard all the necessary information about them and generate the appropriate code during translation.
 There are some rules to name a variable:-
  *  variable name must not start with a digit.

  *  Variable name can consist of alphabets, digits and special symbols like underscore.


  *  Blanks or spaces are not allowed in variable name.


  *  Keywords are not allowed as variable name.


  * upper and lower case names are treated as different ,as C is case-sensitive, so it is suggested to       keep the variable names in lower case.


  

iv> Constants:-
           The quantity which does not change during the execution of a program is known as constant. It is use in assignment statements.Constants are stored in variables. There are five types of constant:-
  *  Character 

  *  Integer


  *  Real (float)


  *  String


  *  Logical


 A character constant is a constant which uses single quotation around characters. For example: 'a' , 'l' etc. An integer constant is a numeric constant without any fractional or exponential part.

 A floating point constant is a numeric constant that has either a fractional form or an exponential form.
 String constants are the constants which are enclosed in a pair of double-quote marks. For example: "good" , " ", "x" .


v> String:-

        String is a collection of more than one character. For ex: "RAM" , " Meerut" . String is represented by a pair of double quotes. the length of a string is determined by a terminating null character('\0') . For using string the header file <string.h> is needed. The nine more commonly used functions in the string library are:-
  *  strcat-- concatenates two strings.

  *  strchr--  string scanning operation.

  *  strcmp-- compair two string.

  *  strcpy-- copy a string.

  *  strlen--  get string length.

  *  strncat--  concatenate one string with part of another.

  *  strncmp--  compare part of two strings.

  *  strncpy--  copy part of a string.

  *  strrchr--string scanning operation.


 vi> Operators:- 
            Operators acts as connectors and they indicate what type of operation is being carried out. The values that can be operated by these operators are called operands. They are used to perform basis operations , comparision , manipulation of bits and so on. The operators include many types which are as follows:-
  *  Arithmetic operators.

  *  Logical operators.

  *  Relational operators.

  *  Assignment operators.

  *  Increment/ Decrement operators.

  *  Bitwise operators.

  *  Special operators.

Comments

Post a Comment

Please comment.

Popular posts from this blog

Process Scheduling And Types of Process Schedular :-

        ⇰ PROCESS SCHEDULING Process Scheduling  is a task  of Operating System that schedules processes of different states like new, ready, waiting, terminated  and running.This scheduling helps in allocation of CPU time for each process, and Operating System allocates the CPU time for each procss. And the process scheduling plays important role to keep the CPU busy all the time.  ⏩   Followings are some objectives of Process Scheduling :-  i > To increase the amount of users within acceptable response times.  ii > To maintain the balance between response and utilization of system. iii > To decrease the enforce priorities and  give reference to the processes holding the key resources.      ⇰  PROCESS SCHEDULAR A scheduler carries out the pro cess scheduling work. Schedulers are often implemented so they keep all computer resources busy and  allows multiple users to share system resources  to achieve  multiprogramming .  There are  mainy three types of pro

Micromax 'The Indian Smart Phone Company'

Micromax  is an Indian  consumer electronics  company headquartered in  Gurgaon ,  Haryana . It was established as an  IT   Software  company operating in the  Embedded Devices   Domain . It later entered the  Mobile   Handset  business. Micromax was incorporated as Micromax Informatics Ltd. on 29 March 2000 by Zeeshan Ali Zaidi. It began selling mobile telephones in 2008,  focusing on  low pricing to compete with international brands. By 2010, Micromax was one of the largest domestic companies making handsets in the low-cost feature phone segment in India. As of Q3 2014, Micromax is the  Tenth Largest   Smart phone  vendor in the world. The company is facing stiff competition from Chinese companies that are penetrating the Indian market. The company also owns  YU Televentures , which sells its products under the brand name YU. The company has also introduced handsets with innovative features. For instance, Micromax's co-founder  Rahul Sharma  once saw a  public call