Home Programming Languages c programming C Tokens

C Tokens


A token is smallest individual unit . C language supports the following tokens.
1.character set.

Character Set

when writing a program statements we are using numbers , words and expressions. Based on that the characters are devided into 4 groups.

  1. Letters(a-z)(A-Z)
    2. Digits(0-9)
    3. White Spaces(tab,enter,space)
    4. Symbols (+ , – = & and so on)


A constant is fixed values which can not change the meaning of value during program execution. Basically constants are two types
1. Numerical Constants
a. Integer Constants
b. Real(Float) constants
2. Character Constants
a. Single character Constants
b. String Constants


Keywords are also called reserved words. These words are used to build the block of program statements. When writing a keyword in program it must be lower case. It has fixed meaning , That meaning can not be changed. C language supports up to 32 keywords. Some of the keywords are as follows.

auto, double, int, struct, break, else, long, switch, case, enum, register, typedef, char, extern, return, union, const, float, short, unsigned, continue, for, signed, void, default, goto, sizeof, volatile, do, if, static, while.


A variable is data name which stores the data value. Unlike constants that remain unchanged . Using variables we can changes the constants. A variable takes a different value at different times. When used a variable in a program it
should be meaningful way. When
used variable we must the following rules.

1. A variable name must begin with a letter.
2. A variable name maximum 31 characters length
3. A variable name should not be keyword.
4. in variable, It does not allow the white spaces and special symbols. But Underscore symbol is allowed.
5.A variable is case sensitive. It means the variable declared in lower case the entire program followed the same case.

Some of valid variable names are as follows.

sum, avg, total, s1, tot_amount.

Some of invalid variables name are as follows

if 1n, t.a, total amount.

Datatypes :

C language supports a rich set of datatypes. For storage representation and machine instruction to handle the constants we can use these data types. The datatype can be divide into three types.

1.built-in Datatypes (primary datatypes)
int char float long
2.Derived Datatypes
Arrays pointers
3.User-Defined Datatypes
structures unions

datatype size (bytes) Range Control Format
short Int 2 -32,768 to 32,767 %hd
unsigned short int 2 0 to 65,535 %hu
int 2 or 4 (It vary based on O.S) -32,768 to 32,767 (or)
-2,147,483,648 to 2,147,483,647
unsigned int 2 or 4 0 to 65,535 (or)
0 to 4,294,967,295
long int 4 -2,147,483,648 to 2,147,483,647 %ld
unsigned long int 4 0 to 4,294,967,295 %lu
float 4 1.2E-38 to 3.4E+38
6 decimal places
double 8 2.3E-308 to 1.7E+308
15 decimal places
long double 10 3.4E-4932 to 1.1E+4932
19 decimal places
char 1 -128to127 or
0 to 255
unsigned char 1 0 to 255 %c
signed char 1 -128 to 127 %c
long long int 8 -(2^63) to (2^63)-1 %lld
unsigned long long int 8 0 to (2^64)-1 %llu

in case of string variable %s.


An Operator is a symbol it tells the compiler either do mathematical and logical calculations. Operators are perform to any calculations on variables. We have already seen some operators + – * / and so on. In C Language The operators are can be divide into the following categories.

  1. Arithmetic Operators.
    2. Relational Operators.
    3. Logical Operators.
    4. Conditional Operator.
    5. Assignment Operator ( = )
    6. Increment and decrement operators.
    7. Bitwise operator.
    8. Other Operators.

Arithmetic Operators

C language supports all basic arithmetic calculations. Such as addition , subtraction, multiply and so on. Those operators are as follows.
Operator meaning
+ Addition
– Subtraction
* Multiply
/ division
% Modulo Division.

Relational Operators

These operators are used to check the relation between two variables. When check the relation it gives either “true” or “false”. To perform those operation C language supports the following relational operators.

Operator Meaning

> grater than
>= grater than or equal
< less than
<= less than or equal
= = Equal to (comparison)
!= Not Equal

Logical Operators

These are additional to relational operators. It used to check the more then one relational expression in your program statements. When check it is also given “true” or “false”. Those are as follows.

Operator meaning
&& (ampersand) and
|| (pipe) or
! (exclamation) not

4.Conditional Operator:

This is combination of “? and :”. it is used to check the small conditions in your program statements. The general syntax of this statement is:
conditionalexpr ? expr1 : expr2 ;

When execute the condition operator first check the conditional expression. It gives either “true” or “false”, If it is true then check the expr1. otherwise check the expr2.

Assignment Operator(=)

if we want assign some to variable using this operator.

Increment && decrement operators

These are most common used operators when perform the loop operations. Using this increase by value one or decrease by value one. Those are as follows.

operator meaning
+ + increment
– – decrement

Bitwise Operators

c has a distinction of supporting special operators known as bitwise operators for manipulation data at bit level.A bitwise operator operates on each bit of data. Those operators are used for testing,complementing or shifting bits to the right on left. bitwise operators may not be applied to a float or long.
Operator meaning
& bitwise AND
| bitwise OR
^ bitwise exclusive
<< shift left
>> shift right

8.Other Operators

Comma Operator
Comma operators are used to link related expressions together. For example:

int a, c = 5, d;

The sizeof operator
The sizeof is an unary operator which returns the size of data (constant, variables, array, structure etc).