Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- int main()
- {
- int decNum{ 17 };
- int hexDigit{ 0 };
- char hexH{ '0' };
- char hexL{ '0' };
- hexDigit = decNum % 16;
- //(hexDigit < 10) and (hexL = '0' + hexDigit);
- //(hexDigit >= 10) and (hexL = 'A' + (hexDigit - 10));
- //(hexDigit < 10) and (hexL = '0' + hexDigit) or (hexL = 'A' + (hexDigit - 10));
- if (hexDigit < 10) { hexL = '0' + hexDigit; }
- else { hexL = 'A' + (hexDigit - 10); };
- decNum /= 16;
- hexDigit = decNum % 16;
- //(hexDigit < 10) and (hexH = '0' + hexDigit);
- //(hexDigit >= 10) and (hexH = 'A' + (hexDigit - 10));
- //(hexDigit < 10) and (hexH = '0' + hexDigit) or (hexH = 'A' + (hexDigit - 10));
- if (hexDigit < 10) { hexH = '0' + hexDigit; }
- else { hexH = 'A' + (hexDigit - 10); };
- std::cout << hexH << hexL << '\n';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement