#include<iostream>
#include<math.h>
using namespace std;
int main()
{ int dec,i,maxi,rem,q,s;
cout<<"decimal number please.....\n";
cin>>dec;rem=dec;
for(i=1;dec>pow(16,i);i++);
--i; //q=quotient represents the hexdecimal equivalent
for(;i>=0;i--)
{ s=pow(16,i);
q=rem/s;
if(q>=10)
{ ;cout<<(char)(q+55);} //55 added to give equivalent ASCII value
else
cout<<q;
rem=rem % s;
}
return 0;
}
#include<math.h>
using namespace std;
int main()
{ int dec,i,maxi,rem,q,s;
cout<<"decimal number please.....\n";
cin>>dec;rem=dec;
for(i=1;dec>pow(16,i);i++);
--i; //q=quotient represents the hexdecimal equivalent
for(;i>=0;i--)
{ s=pow(16,i);
q=rem/s;
if(q>=10)
{ ;cout<<(char)(q+55);} //55 added to give equivalent ASCII value
else
cout<<q;
rem=rem % s;
}
return 0;
}
No comments:
Post a Comment