C++ int type Output the results of applying the ~,& , | and ^ operations
#include <cstdio> #include <cstdlib> #include <iostream> using namespace std; int main(int nNumberofArgs, char* pszArgs[]) { // set output format to hexadecimal cout.unsetf(cout.dec);//from w w w. jav a 2 s.c om cout.setf(cout.hex); // initialize two arguments int nArg1 = 0x78ABCDEF; int nArg2 = 0x12345678; cout << " nArg1 = 0x" << nArg1 << endl; cout << "~nArg1 = 0x" << ~nArg1 << "\n" << endl; cout << " nArg2 = 0x" << nArg2 << endl; cout << "~nArg2 = 0x" << ~nArg2 << "\n" << endl; cout << " 0x" << nArg1 << "\n" << "& 0x" << nArg2 << "\n" << " ----------" << "\n" << " 0x" << (nArg1 & nArg2) << "\n" << endl; cout << " 0x" << nArg1 << "\n" << "| 0x" << nArg2 << "\n" << " ----------" << "\n" << " 0x" << (nArg1 | nArg2) << "\n" << endl; cout << " 0x" << nArg1 << "\n" << "^ 0x" << nArg2 << "\n" << " ----------" << "\n" << " 0x" << (nArg1 ^ nArg2) << "\n" << endl; return 0; }