Toggling using bit-wise XOR Operator


    # include <iostream.h>
    # include <conio.h>
    void main ()
    {
        int a , b ;

        clrscr() ;

        a = 9 ;
        b = 11 ;
        cout<<"original Values= " <<a<<" " <<b ;
        cout <<"\n Toggled Value (a^b) = "<<(a^b);
        cout<<"\n Re-Toggled Value (a^b^b) = "<<(a^b^b);
        a = 6 ;
        b = 4 ;
        cout<<"original Values =  = "<<a<<"" <<b;
        cout<<"\n Toggled Value (a^b)" <<(a^b);
        cout <<"\n Re-Toggled Value (a^b^b) =  "<<(a^b^b);
        getch();
    }

0 comments:

Post a Comment

 
 
 
 


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