programming-examples/c++/_Basic/Binary to Hexadecimal.cpp
2019-11-15 12:59:38 +01:00

17 lines
459 B
C++

#include < iostream.h>
int main()
{
long int binaryval, hexadecimalval = 0, i = 1, remainder;
cout<<"Enter the binary number: ";
cin>>binaryval;
while (binaryval != 0)
{
remainder = binaryval % 10;
hexadecimalval = hexadecimalval + remainder * i;
i = i * 2;
binaryval = binaryval / 10;
}
cout<<"Equivalent hexadecimal value:"<<hexadecimalval;
return 0;
}