Write A C++ Program To Convert A Decimal Number To Its Corresponding Hexadecimal Number.

Write a C++ program to convert a Decimal number to its corresponding Hexadecimal number. (adsbygoogle = window.adsbygoogle || []).push({});
Program Code:#includeusing namespace std;int main(){long int deci, rem, q;char hexa[100];int i=1, j, temp;
cout<<"Enter any decimal number : ";cin>>deci;cout<q = deci;while(q != 0){temp = q % 16;if(temp < 10){temp = temp + 48;}else{temp = temp + 55;}hexa[i++] = temp;q = q / 16;}cout<<"Equivalent hexadecimal value of "<for(j=i-1; j>0; j--){cout<}return 0;
The program output is tested on www.jdoodle.comOutput:Enter any decimal number : 45Equivalent hexadecimal value of 45 is : 2D

(adsbygoogle = window.adsbygoogle || []).push({}); ThanksMukesh Rajput