Monday, 24 December 2012

Variables & Operators:


Variables & Operators:

               Variable is nothing but Memory Location.When using a variable you refer to the memory address of the computer .

Ex:     int a;// Declaration
          int a=10; // Initialization(Here 10 is called constant or Literals).

Operators in C

                      
 Operators are:
1. Arithmetical operators
2. Logical operators
3. Relational operators
4. Bitwise operators
5. Shift operators


Arithmetic operators:

                  These operators are used for the for mathematical expression like (Addition ‘+’, Subtraction ’-’ ,  Multiplication ‘*’ , Division ’/’, Modulus ‘%’)     addition is used to two or more than two expression, same as subtraction is used to find the difference, etc. But there is difference  between division and  modulo i.e., modulo always gives the remainder.
for example: 7%2 then it gives modulo 1 because remainder is 1.


Logical Operators : 

      &&-------------Logical And (a>b&& x==10)
      ||-------------logical OR (a<m||a<n)
      !---------------Logical Not (! (x>=y)  Not exp.evaluates values of x neither greater than or equal to y)




  Assignment operator:    (x=a+b;) means value of (a+b) is stores in x.
     
 Bitwise operator:           (a: 100101 ~a: 011010)
      
 Shift operator:       These are of two types –
                                              a) Right shift(a>>L)
                                              b) Left shift (a<<L)

No comments:

Post a Comment