A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://TheAlgorithms.github.io/C-Plus-Plus/da/de7/decimal__to__hexadecimal_8cpp_source.html below:

TheAlgorithms/C++: others/decimal_to_hexadecimal.cpp Source File

Loading...

Searching...

No Matches

decimal_to_hexadecimal.cpp

Go to the documentation of this file. 12 int

valueToConvert = 0;

// Holds user input 13 int

hexArray[8];

// Contains hex values backwards 15 char

HexValues[] =

"0123456789ABCDEF"

;

17

std::cout <<

"Enter a Decimal Value" 18

<< std::endl;

// Displays request to stdout 20

valueToConvert;

// Stores value into valueToConvert via user input 22 while

(valueToConvert > 15) {

// Dec to Hex Algorithm 23

hexArray[i++] = valueToConvert % 16;

// Gets remainder 25 // valueToConvert >>= 4; // This will divide by 2^4=16 and is faster 27

hexArray[i] = valueToConvert;

// Gets last value 29

std::cout <<

"Hex Value: "

;

30 while

(i >= 0) std::cout << HexValues[hexArray[i--]];

32

std::cout << std::endl;


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4