C++ examples for Data Type:int
Set output format to hexadecimal
#include <cstdio> #include <cstdlib> #include <iostream> using namespace std; int main(int nNumberofArgs, char* pszArgs[]) { // set output format to hexadecimal cout.unsetf(cout.dec);// w ww . j a v a2 s. c o m 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; }