#include <iostream>
usingnamespace std;
int main()
{
long dec,rem,i=1,sum=0;
cout<<"Enter the decimal to be converted:";
cin>>dec;
if(dec<=0){
cout << "Invalid Number!\tEnter a positive number Please\n";
exit(0);
}
do
{
rem=dec%2;
sum=sum + (i*rem);
dec=dec/2;
i=i*10;
}while(dec>0);
cout<<"The binary of the given number is:"<<sum<<endl;
cin.get();
cin.get();
return 0;
}
How can I modify this to find Decimal to Hexadecimal bcz after 9,hexadecimal notation starts with A,B,...