1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
#include "stdafx.h"
#include<iostream>
using namespace std;
void dectohex( char dectohexa[],const int arreysize);
int _tmain(int argc, _TCHAR* argv[])
{
int number;
cout<<"Enter the decimal number:";
cin>>number;
cout<<"DecimaltoHex:\n";
const int arreysize=1000;
int i=0,remain;
char printarrey[arreysize],dectohexa[arreysize];
dectohex(dectohexa,arreysize);
while(number!=0)
{
remain=number%16;
number=number/16;
printarrey[i]=dectohexa[remain];
i++;
}
i--;
for(i;i>=0;i--)
{
cout<<printarrey[i];
}
return 0;
}
void dectohex(char dectohexa[],const int arreysize=15)
{
dectohexa[arreysize] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
}
|