adsense

Hii, welcome to my site. My name is Om prakash kartik. This blog helps you to learn programming languages concepts.

Program in C++ to Convert Decimal to Hexadecimal number Using Function

Program in C++ to Convert Decimal to Hexadecimal number Using Function



#include<iostream>
#include<conio.h>
#include<string.h>
 using namespace std;
  void DecToHexa(int dec,char hexa[])
    {
        int temp,i;
        i=0;
      while(dec!=0)
       {
        temp=dec%16;
        if(temp>=10)
           temp+=55;
        else
           temp+=48;
         hexa[i++]=temp;
        dec=dec/16; 
    }
   strrev(hexa);
 }
 
   int main()
    {
     int dec;
     cout<<"Enter a No.:-";
     cin>>dec;
     char hex[100];
     DecToHexa(dec,hex);
     cout<<"HexaDecimal No.="<<hex;
     getch();
    }
Output:-






Post a Comment

0 Comments