hexadecimal to decimal c++ code example
Example 1: decimal to hex cpp
// Pretty stright forward
// takes in input
// outputs it in hex
#include <iostream>
using namespace std;
int main(){
float i;
cout << "What is the number?: ";
cin >> i;
int* q = (int*)&i;
cout << hex << *q << endl;
return 0;
}
Example 2: Convert a hexadecimal number into decimal c++
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int x;
cin >>hex >> x;
cout << x << endl;
return 0;
}