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 ;
    }

No comments:

Post a Comment