17 lines
459 B
C++
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;
|
|
} |