Basic theory for 'C' Language

                                                              (Page : 1)

Basic Definitions :

1. Tokens in C


* C tokens are the basic buildings blocks in C language which are constructed together to write a C program.
* Each and every smallest individual units in a C program are known as C tokens.
*A token is either a keyword, an identifier, a constant, a string literal, or a symbol.

Types of tokens in 'C' :

Keywords                ( eg: int, while ),
Identifiers               ( eg: main, total ),
Constants                ( eg: 10, 20 ),
Strings                     ( eg: “total”, “hello” ),
Special symbols      ( eg: (), {} ),
Operators                ( eg: +, /,-,* )



For example, the following C statement consists of  five tokens: 


                      printf ("My first c program \n"); 

The individual tokens are:

           printf                                                    
          ( 
           "My first c program \n
           ) 
          ; 
                     

2. Why Semicolons ( ; ) are used  

In C program, the semicolon is a statement terminator. That is, each individual statement 
must be ended with a semicolon. It indicates the end of one logical entity and while compiling the compiler considers next line after it encounters semicolon.

For example, following are two different statements: 

printf ("My first C Program \n"); 
return 0; 

   
3. Comments in 'C'

Comments are helping text in your C program, they are indented for human reading and they are ignored by the compiler. 

3.1 They start with "/ * " and terminates with the characters " */ " as shown below: 

/* My first c program */ 

3.2  for commenting a line only we use // 

eg: // thec-language.blogspot.com

the difference between  the two is that in 1st one the whole lines or para within /*  */ is considered as comment whereas in the second one if you put // before a line in program only that line will be considered as a comment.




                                                                  HOME                             Next page >>