C OPERATORS

|

Operators Introduction

An operator is a symbol which helps the user to command the computer to do a certain mathematical or logical manipulations. Operators are used in C language program to operate on data and variables. C has a rich set of operators which can be classified as

  •  Arithmetic operators
  •  Relational Operators
  •  Logical Operators
  •  Assignment Operators
  •  Increments and Decrement Operators
  •  Conditional Operators
  •  Bitwise Operators
  •  Special Operators

1. Arithmetic Operators

All the basic arithmetic operations can be carried out in C. All the operators have almost the same meaning as in other languages. Both unary and binary operations are available in C language. Unary operations operate on a singe operand, therefore the number 5 when operated by unary – will have the value –5.


Examples of arithmetic operators are

x + y
x - y
-x + y
a * b + c
-a * b

etc.,

here a, b, c, x, y are known as operands. The modulus operator is a special operator in C language which evaluates the remainder of the operands after division.

Example


Integer Arithmetic

When an arithmetic operation is performed on two whole numbers or integers than such an operation is called as integer arithmetic. It always gives an integer as the result. Let x = 27 and y = 5 be 2 integer numbers. Then the integer operation leads to the following results.

x + y = 32
x – y = 22
x * y = 115
x % y = 2
x / y = 5

In integer division the fractional part is truncated.

Floating point arithmetic

When an arithmetic operation is preformed on two real numbers or fraction numbers such an operation is called floating point arithmetic. The floating point results can be truncated according to the properties requirement. The remainder operator is not applicable for floating pointarithmetic operands.

Let x = 14.0 and y = 4.0 then

x + y = 18.0
x – y = 10.0
x * y = 56.0
x / y = 3.50

Mixed mode arithmetic

When one of the operand is real and other is an integer and if the arithmetic operation is carried out on these 2 operands then it is called as mixed mode arithmetic. If any one operand is of real type then the result will always be real thus 15/10.0 = 1.5

2. Relational Operators

Often it is required to compare the relationship between operands and bring out a decision and program accordingly. This is when the relational operator come into picture. C supports the following relational operators.



It is required to compare the marks of 2 students, salary of 2 persons, we can compare them using relational operators.

A simple relational expression contains only one relational operator and takes the following form.

exp1 relational operator exp2

Where exp1 and exp2 are expressions, which may be simple constants, variables or combination of them. Given below is a list of examples of relational expressions and evaluated values.

6.5 <= 25 TRUE -65 > 0 FALSE
a> b && x = = 10

The expression to the left is a > b and that on the right is x == 10 the whole expression is true only if both expressions are true i.e., if a is greater than b and x is equal to 10.

3. Logical Operators

C has the following logical operators, they compare or evaluate logical and relational expressions.



Logical AND (&&)

This operator is used to evaluate 2 conditions or expressions with relational operators simultaneously. If both the expressions to the left and to the right of the logical operator is true then the whole compound expression is true.

Example

a > b && x = = 10

The expression to the left is a > b and that on the right is x == 10 the whole expression is true only if both expressions are true i.e., if a is greater than b and x is equal to 10.

Logical OR (||)

The logical OR is used to combine 2 expressions or the condition evaluates to true if any one of the 2 expressions is true.

Example

a!=20 || b==6 evaluates to true if any one of them is true or if both of them are true.
It evaluates to true if a is less than either m or n and when a is less than both m and n.

Logical NOT (!)

The logical not operator takes single expression and evaluates to true if the expression is false and evaluates to false if the expression is true. In other words it just reverses the value of the expression.
For example

! (x >= y)

the NOT expression evaluates to true only if the value of x is neither greater than or equal to y


4. Assignment Operators

The Assignment Operator evaluates an expression on the right of the expression and substitutes it to the value or variable on the left of the expression.

Example

x = a + b

Here the value of a + b is evaluated and substituted to the variable x.

In addition, C has a set of shorthand assignment operators of the form.

var oper = exp;

Here var is a variable, exp is an expression and oper is a C binary arithmetic operator. The operator oper = is known as shorthand assignment operator


Example

x + = 1 is same as x = x + 1

The commonly used shorthand assignment operators are as follows

Shorthand assignment operators



Example for using shorthand assignment operator


Output

2
4
16

5. Increment and Decrement Operators
 
The increment and decrement operators are one of the unary operators which are very useful in C language. They are extensively used in for and while loops. The syntax of the operators is given below

1. ++ variable name
2. variable name++
3. – –variable name
4. variable name– –

The increment operator ++ adds the value 1 to the current value of operand and the decrement operator – – subtracts the value 1 from the current value of operand. ++variable name and variable name++ mean the same thing when they form statements independently, they behave differently when they are used in expression on the right hand side of an assignment statement.

Consider the following

m = 5;
y = ++m; (prefix)

In this case the value of y and m would be 6

Suppose if we rewrite the above statement as

m = 5;
y = m++; (post fix)

Then the value of y will be 5 and that of m will be 6. A prefix operator first adds 1 to the operand and then the result is assigned to the variable on the left. On the other hand, a postfix operator first assigns the value to the variable on the left and then increments the operand.

6. Conditional or Ternary Operator
 
The conditional operator consists of 2 symbols the question mark (?) and the colon (:)
The syntax for a ternary operator is as follows

exp1 ? exp2 : exp3

The ternary operator works as follows

exp1 is evaluated first. If the expression is true then exp2 is evaluated & its value becomes the value of the expression. If exp1 is false, exp3 is evaluated and its value becomes the value of the expression. Note that only one of the expression is evaluated.

For example

a = 10;
b = 15;
x = (a > b) ? a : b

Here x will be assigned to the value of b. The condition follows that the expression is false therefore b is assigned to x.


/* Example : to find the maximum value using conditional operator)


Output

Input 2 integers : 34 45
The largest of two numbers is 45

7. 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 double.



8. Special Operators
 
C supports some special operators of interest such as comma operator, size of operator, pointer operators (& and *) and member selection operators (. and ->). The size of and the comma operators are discussed here. The remaining operators are discussed in forth coming chapters.

The Comma Operator:


The comma operator can be used to link related expressions together. A comma-linked list of expressions are evaluated left to right and value of right most expression is the value of the combined expression.

For example the statement
value = (x = 10, y = 5, x + y);

First assigns 10 to x and 5 to y and finally assigns 15 to value. Since comma has the lowest precedence in operators the parenthesis is necessary. Some examples of comma operator are

In for loops:

for (n=1, m=10, n <=m; n++,m++)
In while loops
While (c=getchar(), c != ‘10’)
Exchanging values
t = x;
x = y;
y = t;

The size of Operator:
 
The operator size of gives the size of the data type or variable in terms of bytes occupied in the memory. The operand may be a variable, a constant or a data type qualifier.
Example
m = sizeof (sum);
n = sizeof (long int);
k = sizeof (235L);
The size of operator is normally used to determine the lengths of arrays and structures when their sizes are not known to the programmer. It is also used to allocate memory space dynamically to variables during the execution of the program.
Example program that employs different kinds of operators. The results of their evaluation are also shown in comparison .



Assumes the value 0 when c is less than d and 1 when c is greater than d.

Type Modifiers

|

In addition, these data types have some modifiers preceding them. The use of these modifiers changes the meaning of the base type.

The memory in the computer is organized in terms of units called bytes. One byte consists of 8 bits and bit is a smallest unit of memory.
Need of Data Modifiers:

Let us take an example of a Program where we need to input the “Salary” of “Employees” in a team. This program will accept the salary as an input from user and then calculate the Income Tax of that user. We use “int” to store the Salary of the employee as we are assuming that the salary will be in “Whole Numbers”.

An integer data type takes 2 Bytes of Memory and we are aware that the Salary of any of the employee can not be “Negative”. We are using “2 Bytes” to store the memory of an Employee and we can easily save 1 Byte over there by removing the “Signed Part” in the integer. This positive value can easily be stored in “1 Bye Int” This leads us to the user of Data Type Modifiers.
Types of Data Modifiers in C:

The modifiers are listed below :

Signed Type Modifier:

All data types are “signed” by default. Signed Data Modifier implies that the data type variable can store positive values as well as negative values.

For example, if we need to declare a variable to store temperature, it can be negative as well as positive.

signed int temperature;

Or

int temperature;

Unsigned Type Modifier:

If we need to change the data type so that it can only store only store positive values, “unsigned” data modifier is used.

For example, if we need to declare a variable to store the salary of an employee as explained above, we will use “Unsigned” Data Qualifier here.

unsigned int salary;

Long Type Modifier:

Sometimes while coding a program, we need to increase the Storage Capacity of a variable so that it can store values higher than its maximum limit which is there as default. In such situations or programs, we need to make use of the “long” data type qualifier. “long” type modifier doubles the “length” of the data type when used along with it.

For example, if we need to store the “annual turnover” of a company in a variable, we will make us of this type qualifier.

long int turnover;

This variable will take 4 Bytes in memory.

Short Type Modifier:

A “short” type modifier does just the opposite of “long”. If one is not expecting to see high range values in a program and the values are both positive & negative.

For example, if we need to store the “age” of a student in a variable, we will make use of this type qualifier as we are aware that this value is not going to be very high.

short int age;

This variable will consume only 1 Byte in memory.

We can apply the above mentioned modifiers to integer (int) and character (char) base types.

1. Integer Type Modifiers:

* We can use all the above mentioned Type Modifiers for int data type in C Language
* Short int and long int are also termed as short and long respectively.
* Int is signed & unsigned by default.

2. Character Type Modifiers:

* Variables of type char consume 1 byte in memory.
* Char can be signed or unsigned only.
* They have a range of -128 to 127 and 0 to 255 for signed & unsigned respectively.

3. Float Type & Double Type Modifier:

There are 3 types of float type modifiers as given below:

* float
* double
* long double

Double is same as long float. Float type occupies 4 bytes of memory. Type double occupies 8 bytes. Long double occupies 10 bytes. The exception to this is long double, which modifies the size of the double data type to 10 bytes. Please note that in some compilers this has no effect.

Note: We may use long modifier with double data type but it cannot be used with float, i.e. long double is allowed but long float is not allowed because long float is equal to double.

DATA TYPES

|


C has a concept of 'data types' which are used to define a variable before its use. The definition of a variable will assign storage for the variable and define the type of data that will be held in the location.
“Data types” are defined as ways or means to identify the type of data and associated operations of handling it.


Generally c have following three types of data types
(1) Fundamental or Built-in or Primitive Data Types

(2) User Defined Data Types

(3) Derived Data Types




(1) Fundamental or Built-in or Primitive Data Types

C has the following basic built-in data types.
  •   int
  •   char
  •   float
  •   double
  •   void
  • Integer Types
Integers are whole numbers with a range of values, range of values are machine dependent. Generally an integer occupies 2 bytes memory space and its value range limited to -32768 to +32768 (that is, -215 to +215-1). A signed integer use one bit for storing sign and rest 15 bits for number.
To control the range of numbers and storage space, C has three classes of integer storage namely short int, int and long int. 

All three data types have signed and unsigned forms. A short int requires half the amount of storage than normal integer. Unlike signed integer, unsigned integers are always positive and use all the bits for the magnitude of the number. Therefore the range of an unsigned integer will be from 0 to 65535. The long integers are used to declare a longer range of values and it occupies 4 bytes of storage space.

Syntax:

int variable_name; /*declaration*/

short int num2;      /*declaration*/

long int num3;       /*declaration*/

Example: 5, 6, 100, 2500.

Integer Data Type Memory Allocation

  • Floating Point Types:
The float data type is used to store fractional numbers (real numbers) with 6 digits of precision. Floating point numbers are denoted by the keyword float. When the accuracy of the floating point number is insufficient, we can use the double to define the number. The double is same as float but with longer precision and takes double space (8 bytes) than float. To extend the precision further we can use long double which occupies 10 bytes of memory space.

Syntax: float variable_name; /*declaration*/


float num1;                            /*declaration*/

double num2;                        /*declaration*/

long double num3;               /*declaration*/

Example: 9.125, 3.1254.

  •   Character Type:
Character type variable can hold a single character. As there are singed and unsigned int (either short or long), in the same way there are signed and unsigned chars; both occupy 1 byte each, but having different ranges. Unsigned characters have values between 0 and 255, signed characters have values from –128 to 127.

Syntax:
char ch; /*declaration*/


char ch = ‘a’; /*declaration + initilasization*/

Example: a, b, g, S, j.



  • Void Type:
The void type has no values therefore we cannot declare it as variable as we did in case of integer and float.
The void data type is usually used with function to specify its type. Like in our first C program we declared “main()” as void type because it does not return any value. The concept of returning values will be discussed in detail in the C function hub.

Modifier
The data types explained above have the following modifiers.

  •   short
  •   long
  •   signed
  •   unsigned

The modifiers define the amount of storage allocated to the variable. The amount of storage allocated is not cast in stone. ANSI has the following rules:

short int <= int <= long int

float <= double <= long double

What this means is that a 'short int' should assign less than or the same amount of storage as an 'int' and the 'int' should be less or the same bytes than a 'long int'. What this means in the real world is:
You can find out how much storage is allocated to a data type by using the sizeof operator discussed in Operator Types Session.
Here is an example to check size of memory taken by various data types.

For more details on modifier click here.



Program to find out the size of data types :

main()
{
   printf("sizeof(char) == %d\n", sizeof(char));
   printf("sizeof(short) == %d\n", sizeof(short));
   printf("sizeof(int) == %d\n", sizeof(int));
   printf("sizeof(long) == %d\n", sizeof(long));
   printf("sizeof(float) == %d\n", sizeof(float));
   printf("sizeof(double) == %d\n", sizeof(double));
   printf("sizeof(long double) == %d\n", sizeof(long double));
   printf("sizeof(long long) == %d\n", sizeof(long long));
   return 0;
 }

Qualifier
A type qualifier is used to refine the declaration of a variable, a function, and parameters, by specifying whether:
The value of a variable can be changed.
The value of a variable must always be read from memory rather than from a register
Standard C language recognizes the following two qualifiers:

  •   const
  •   volatile
Const :
The const qualifier is used to tell C that the variable value can not change after initialisation.
const float pi=3.14159;
Now pi cannot be changed at a later time within the program.
Another way to define constants is with the #define preprocessor which has the advantage that it does not use any storage


Volatile :
The volatile qualifier declares a data type that can have its value changed in ways outside the control or detection of the compiler (such as a variable updated by the system clock or by another program). This prevents the compiler from optimizing code referring to the object by storing the object's value in a register and re-reading it from there, rather than from memory, where it may have changed. You will use this qualifier once you will become expert in "C". So for now just proceed.



Size of data type in c (Turbo C++ compiler)

Only two modifiers short and long can affect the size of any data type in c. size of primitive data type in c depends upon the word length of the microprocessor. In general we can say size of int is word length of microprocessor.






Size of data types in the 16 bit compilers, like TURBO c++, Borland c++ etc.


Size of data type in c (Linux gcc compiler)

Size of data types in the 32 bit compilers. Example: LINUX gcc compiler.



(2) User Defined Data Types
C support user-defined data types. Once a user-defined type has been established, then new variables, array, structures etc. can be declared in the terms of this new data type. In C language user-defined data types are: typedef & enum.

  •   typedef
  •   enum
  •   structure
  •   union
  • Typedef
typedef is an abbreviation used for “Type Definition”. Its purpose is to redefine the name of an existing data type. This can be later used to declare variables. Its general form is:
typedef standard-datatype userdefined-datatype.
Ex:
(i) typedef int age;
int x;
age p,q,r,s;
Here, all the variables are holding integer value but age helps us to understand
that these 4 variables will hold age. It helps users debugging the program.
(ii) struct student

{
char name [30];
int roll_no;
float percent;
};
struct student s;
Using typedef:
struct student

{
char name [30];
int roll_no;
float percent;
};
typedef struct student STU;
STU s1, s2;

  • Enum
The enumerated data type gives us an opportunity to invent our own data type and define what values the variables of this data type can take. Its general form is:
enum datatype-name {val1,val2,…..,valn};
Ex:-
(i)
enum weekdays
{Sunday, Monday, Thursday, Wednesday, Thursday, Friday, Saturday};
weekdays x, y;



(ii)
enum marks {gradeA=1, gradeB=2, gradeC=3};
enum marks s1, s2;
The values declared by enum are ordinal nos. Ordinal values starts from zero.

  •  Structures
A Structure can be defined as a collection or a group of variables that are referenced under one name. it is used to keep related information together. Here we use a ‘struct’ keyword to construct a structure.
Example:
Struct bank
{
Char name[30];

Int account_no;

Int amount;
};
Struct b;


In the above example bank is the name of the structure, then we have declared the variables which are the elements of this structure. And b is the object of the structure which is used to refer the elements of the structure.

Elements will be referred as :
b.amount=5000;
b.account_no=2546321;

  • Union
Groups variables which share the same storage space.
A union is similar to a struct, except it allows you to define variables that share storage space. The syntax for defining unions is:

union [union-type-name] { type variable-names; ... } [union-variables] ;


For example,union short_or_long { short i; long l; } a_number;


The compiler will allocate enough storage in a number to accommodate the largest element in the union. Elements of a union are accessed in the same manner as a struct.




Unlike a struct, the variables 'a_number.i' and 'a_number.l' occupy the same location in memory. Thus, writing into one will overwrite the other.






(3) Derived Data Types

Derived data types in C Programming Language are those C data types which are derived from the fundamental data types using some declaration operators.
  • Array
  • Function
  • Pointers
Arrays:
Arrays can be defined as a set of finite and homogeneous data elements. Each element of an array is referenced using an index.
For example:
If we the name of an array is AR which have 5 elements then the array will be represented as :
AR[0], AR[1], AR[2], AR[3], AR[4]
Here, these subscripts which are containing the digit is known as an index.
There are various types of arrays namely:


* One dimensional

* Two dimensional

* Multi dimensional

The elements of an array are indexed from 0 to size-1. It is necessary to declare the size of an array before initialization. An array can be initialize by placing the elements of an array within the curly braces.
For example, an array initialization can be done in following manner:

int AR[5] = {5, 2, 6, 8, 3};
A sample program of an array:

Void main()

{

int arr[10];

arr[10] = {1,5,4,6,3,9,14,81,7,11};

printf(“\n %d”,arr[i]);

}

2. Functions
A function can be defined as a part of the program which is declared by the programmer in any part of the program and a function can be of any name depending upon the choice of the programmer. The function declared can be invoked from other part of the program.
Example of a function:
#include

Float square(float);

Void main()

{

Float num=3.14;

Float sq;

Sq=square(num);

Printf(“%f”,sq);

}


Float square(float x)

{

Return x * x;

}

The above code will print the square of the above given number. square is the name of the function used. And sq is the variable used to store the value of the square. The use of the function before the main function is known as declaration of the function, then comes the definition of a function which takes place outside the main function. Then finally comes the calling of the function which takes place inside the main function.

3. Pointers
A pointer is a variable that holds the address of the memory space. We can say that if one variable can hold the address of the another variable then it is said that the first variable is pointing to the second.
A pointer is declared in a following manner:


int *temp;


i.e. first we have to declare the type and then the variable name precede by an * (asterisk) sign.

The pointer variable always occupies 2 bytes of memory.

C Variables

|

A variable is just a named area of storage that can hold a single value (numeric or character). The C language demands that you declare the name of each variable that you are going to use and its type, or class, before you actually try to do anything with it.
                                                                                                                                    
The Programming language C has two main variable types 
  1. Local Variable
  2. Global Variable 
      Local Variable :
      • Local variables scope is confined within the block or function where it is defined.Local variables must always be defined at the top of a block.  
      • When a local variable is defined - it is not initalised by the system,you must initalise it yourself.  
      • When execution of the block starts thevariable is available, and when the block ends the variable 'dies'.
      Check following example's output

      This will generate following output
      i is 5
      i is 100
      i is 5
      Here ++ is called incremental operator and it increase the value of any integer variable by 1. Thus i++ is equivalent to i = i + 1;
      You will see -- operator also which is called decremental operator and it idecrease the value of any integer variable by 1. Thus i-- is equivalent to i = i - 1;

      Global Variables :

      • Global variable is defined at the top of the program file and it can be visible and modified by any function that may reference it.
      • Global variables are initalised automatically by the system when you define them!



      Data Type Initialiser
      int 0
      char '\0'
      float 0
      pointer NULL


      If same variable name is being used for global and local variable then local variable takes preference in its scope. But it is not a good practice to use global variables and local variables with the same name.

      This will generate following output
        Value of i = 11 -- func() function
        Value of i = 5 -- main function
        i in main function is global and will be incremented to 5. i in func is internal and will be incremented to 11. When control returns to main the internal variable will die and and any reference to i will be to the global.



        History of C language

        |

        C language was developed in the 1970 by Dennis Ritchie at Bell Telephone at Bell Telephone Laboratories,Inc(called AT&T Bell Laboratories). Until 1978 C was mostly used within the Bell laboratories. In 1978 Brain Kernighan and Ritchie published a definitive description of the language referred to as K & R version of C.
        After the publication of the K&R description many desirable features of C impressed computer professionals.By the mind of 1980 the popularity of C had become widespread. Numerous C compilers and interpreters had been written for different Operating systems.Most of the commercial implementations of C were some what different from K & T version of C. This created some minor incompatibilities among different implementations of the language. Therefore, the ANSI (American National Standard Institute) worked on a standard version of C language.

        Characteristics of C language
        The following are the features of C language:
        • C is an All purpose programming language.It is equally suitable for generating high level application and low level application.
        • C language encourages the users to write their own library function so that they can extend the features of the language.
        • C program can be executed on any type of computers.
        • The program written in C language can be converted into machine language more efficiently.
        • Computer games can be generated in C language which is accomplished through the usage of sound graphics.
        • C is close to hardware.
        • Both low and high level programming can be done in C language.
        • Another feature of C language is the address manipulation which can be done through the usage of pointers.

        C Tokens

        |

        In a C source program, the basic element recognized by the compiler is the "token." A token is source-program text that the compiler does not break down into component elements.

        TOKENS:
         
        • Keyword   
        • Identifier    
        • Constant\Literal 
        • Variable    
        • Operator
        • Punctuator  
         
        1. KEYWORD :
        "Keywords" are words that have special meaning to the C compiler. An identifier cannot have the same spelling and case as a C keyword. C language uses the following keywords:
        autodoubleintstruct
        breakelselongswitch
        caseenumregistertypedef
        charexternreturnunion
        constfloatshortunsigned
        continueforsignedvoid
        defaultgotosizeofvolatile
        doifstaticwhile
        You cannot redefine keywords. However, you can specify text to be substituted for keywords before compilation by using C preprocessor directives.
                                                                                                                         
        2. IDENTIFIERS :
               "Identifiers" or "symbols" are the names you supply for variables, types, 
                functions, and labels in your program. Identifier names must differ in   
                spelling andcase from any keywords. You cannot use keywords (either C 
                or Microsoft) as identifiers; they are reserved for special use. You create
                an identifier by specifying it in the declaration of a variable, type, or
                function.        
               Once declared, you can use the identifier in later program statements to
               refer to the associated value.
               A special kind of identifier, called a statement label, can be used in goto
               statements. (Declarations are described in Declarations and Types
               Statement  labels are described in The goto and Labeled Statements.) 
        Syntax
               identifier:
          nondigit identifier      nondigit identifier digit
               nondigit: one of
        _ a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
               digit: one of
        0 1 2 3 4 5 6 7 8 9
               The first character of an identifier name must be a nondigit (that is,
               the first character must be an underscore or an uppercase or lowercase
               letter). ANSI allows six significant characters in an external identifier's
               name and 31 for names of internal (within a function) identifiers. External
               identifiers (ones declared at global scope or declared with storage class
               extern) may be subject to additional naming restrictions because these
               identifiers have to be processed by other software such as linkers.

        Characteristic of identifier:
        • The first character must be an alphabet or an underscore.
        • It must consist of only letters, digits or underscore.
        • Only first 31 characters are significant, i.e. if the user enters an identifier of more than 31 characters, the compiler considers only first 31 characters & deletes the others.
        • A keyword cannot be used as an identifier name. 
        • It cannot contain any spaces

                                                                                                                     
          3. CONSTANTS :
                  A constant value is the one which does not change during the execution
                  of a program. C supports several types of constants.
          1. Integer Constants     
          2. Real Constants     
          3. Single Character Constants      
          4. String Constants
          Integer Constants
                 An integer constant is a sequence of digits. There are 3 types of integers
                 namely decimal integer, octal integers and hexadecimal integer.

          Decimal Integers :
                 Decimal integer constant consists of a set of digits 0 to 9 preceded by an
                 optional + or - sign. Spaces, commas and non digit characters are not
                 permitted between digits. Example for valid decimal integer constants
                 are
                 123
                 -310562321
                 +78
                 Some examples for invalid integer constants are
                 15 750
                 20, 000
                 Rs. 1000

          Octal Integers :
                 Octal integer constant consists of any combination of digits from 0
                 through 7 with a O at the beginning. Some examples of octal integers
                 are
                 O26O
                 O347
                 O676

          Hexadecimal integer:
                 Hexadecimal integer constant is preceded by OX or Ox, they may
                 contain alphabets from A to F or a to f. The alphabets A to F refers
                 to 10 to 15 in decimal digits. Example of valid hexadecimal integers
                 are
                 OX2
                 OX8C
                 OXbcd
                 Ox

          Real Constants

                 Real Constants consists of a fractional part in their representation.
                 Integer constants are inadequate to represent quantities that vary
                 continuously. These quantities are represented by numbers containing
                 fractional parts like 26.082. Example of real constants are 0.0026
                -0.974 35.29 +487.0. Real Numbers can also be represented by
                 exponential notation. The general form for exponential notation is
                 mantissa exponent. The mantissa is either a real number expressed in
                 decimal notation or an integer. The exponent is an integer number with
                 an optional plus or minus sign

          Single Character constants

                 A Single Character constant represent a single character which is
                 enclosed in a pair of quotation symbols.Example for character
                 constants are

                        '5'

                        'x'

                        ';'

                        ' '

                 All character constants have an equivalent integer value which are
                 called ASCII Values.

          String Constants
                 A string is a sequence of characters enclosed in double quotes. The
                 sequence of characters may contain letters, numbers, special characters
                 & blank spaces.
                 For eg:-

                             “HELLO!”
                             “1987”
                             “Well Done”
                             “?.....!”
                             “x”

                  A subtype of strings are Escape Sequences/Backslash character
                  constants. They are string s that do not get printed on screen but
                  have their own importance when executed.

                   \a - audible alert(bell)
                   \b - back space
                   \f - form feed
                   \n - new line
                   \r - carriage return
                   \t - horizontal tab
                   \v - vertical tab
                   \' - single quote
                   \” - double quote
                   \? - question mark
                   \\ - backslash
                   \0 - null
                                                                                                                    
          4. VARIABLE :
                  For details : click here
                                                                                                                    
          5. OPERATOR :
                  For details : click here
                                                                                                                    



          Introduction

          |

          C is a general-purpose programming language. It has been closely associated with the UNIX operating system where it was developed, since both the system and most of the programs that run on it are written in C. The language, however, is not tied to any one operating system or machine; and although it has been called a "system programming language'' because it is useful for writing compilers and operating systems, it has been used equally well to write major programs in many different domains.Many of the important ideas of C stem from the language BCPL, developed by Martin Richards. The influence of BCPL on C proceeded indirectly through the language B, which was written by Ken Thompson in 1970 for the first UNIX system on the DEC PDP-7. BCPL and B are ``typeless'' languages. 

          By contrast, C provides a variety of data types. The fundamental types are characters, and integers and floating point numbers of several sizes. In addition, there is a hierarchy of derived data types created with pointers, arrays, structures and unions. Expressions are formed from operators and operands; any expression, including an assignment or a function call, can be a statement. Pointers provide for machine-independent address arithmetic.C provides the fundamental control-flow constructions required for well-structured programs: statement grouping, decision making (if-else), selecting one of a set of possible values (switch), looping with the termination test at the top (while, for) or at the bottom (do), and early loop exit (break).
          Functions may return values of basic types, structures, unions, or pointers. Any function may be called recursively. Local variables are typically ``automatic'', or created anew with each invocation. Function definitions may not be nested but variables may be declared in a block-structured fashion. The functions of a C program may exist in separate source files that are compiled separately. Variables may be internal to a function, external but known only within a single source file, or visible to the entire program. A preprocessing step performs macro substitution on program text, inclusion of other source files, and conditional compilation.C is a relatively "low-level'' language. This characterization is not pejorative; it simply means that C deals with the same sort of objects that most computers do, namely characters, numbers, and addresses. These may be combined and moved about with the arithmetic and logical operators implemented by real machines.