Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Program: hexa.cc
- // Author: Yoan Pinzon
- // Date: Agosto 30, 2006
- #include <iostream>
- using namespace std;
- int main()
- {
- int n;
- while (cin >> n)
- {
- cout << "decimal: " << n << endl;
- // print hex with leading zeros
- cout << "hex : ";
- for (int i=2*sizeof(int) - 1; i>=0; i--)
- {
- cout << "0123456789ABCDEF"[((n >> i*4) & 0xF)];
- }
- cout << endl << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement