➽ Program:-

#include<iostream>

#include<math.h>

using namespace std;

int main()

{

    int binary_number, hexadecimal_number[20], i, temp=0, rem;

    cout << "Enter the Binary Number: ";

    cin >> binary_number;

    cout << "Hexadecimal value is ";

   

    for(i=0; binary_number>0; i++)

    {

        for(int x=0; x<4; x++)

        {

           rem = binary_number % 10;

           binary_number /= 10;

           temp += rem * pow(2,x);

        }

        hexadecimal_number[i] = temp;

        temp = 0;

    }

   

    while(i>0)

    {

        i--;

        if(hexadecimal_number[i] > 9)

           cout << char(55 + hexadecimal_number[i]);

        else

           cout << hexadecimal_number[i];

    }

    return 0;

}

➽ Output:-

Enter the Binary Number: 10101
Hexadecimal value is 15