➽ Program:-

#include<iostream>

#include<string.h>

using namespace std;

int main()

{

    int decimal_number, quotient, rem, i=1, j, temp;

    char hexadecimal_number[100];

    cout << "Enter any Decimal Number: ";

    cin >> decimal_number;

    quotient = decimal_number;

 

    while(quotient != 0)

    {

        temp = quotient % 16;

        if(temp < 10)

           temp = temp + 48;

        else

           temp = temp + 55;

       

        hexadecimal_number[i++] = temp;

        quotient = quotient / 16;

    }

 

    cout << "Hexadecimal value is ";

 

    for(j = i -1; j > 0 ; j--)

       cout << hexadecimal_number[j];

    return 0;

}

➽ Output:-

Enter any Decimal Number: 1789
Hexadecimal value is 6FD