Multiplication & Division using Left Shift & Right Shift


    #include <iostream.h>
    void main ()
    {
        int a = 4 , b = 7 ;
        int x ;
        x = a << 1 ;
        cout<<"Number="<<a<<endl ;
        cout<< "Single Left Shift = "<<x<<endl ;
        x = a >> 1 ;
        cout <<"Single Right Shift = "<<x<<endl ;
        x = b << 1 ;
        cout<<"Number ="<<x<<endl;
        cout<<"Single Left Shift = "<<x<<endl ;
        x = b >> 1 ;
        cout<<"Single Right Shift = "<<x<<endl ;
    }

0 comments:

Post a Comment

 
 
 
 


Copyright © 2012 http://codeprecisely.blogspot.com. All rights reserved |Term of Use and Policies|