- Home
- Course Category
- Course Result
- Course Detail
Hot Line: 0124-2383121
Course Introduction
Programs for practice
In the program below, we've asked user to enter Binary and convert to Hexadecimal ;in C++
Source Code:Convert Binary to Hexadecimal
/* C++ Program - Binary to Hexadecimal */ #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(); }Output
Enter Binary Number :1101 Equivalent hexadecimal value of 1101 is: 44D