C++ Programming Code Examples C++ > Conversions Code Examples Convert Binary to Hexadecimal Convert Binary to Hexadecimal To convert binary to hexadecimal in C++ Programming, you have to ask to the user to enter any number in binary to convert it into hexadecimal, then display the equivalent hexadecimal value on the screen as shown here in the following program. Following C++ program ask to the user to enter any number in binary form to convert it into hexadecimal form, then display the result on the screen: #include<iostream.h> #include<conio.h> void main() { clrscr(); long int binnum, rem, quot; int i=1, j, temp; char hexdecnum[100]; cout<<"Enter Binary Number : "; cin>>binnum; quot = binnum; while(quot!=0) { temp = quot % 16; // To convert integer into character if( temp < 10) { temp = temp + 48; } else { temp = temp + 55; } hexdecnum[i++]= temp; quot = quot / 16; } cout<<"Equivalent hexadecimal value of "<<binnum<<" is :\n"; for(j=i-1 ;j>0;j--) { cout<<hexdecnum[j]; } getch(); }