Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <conio.h>
- using namespace std;
- int main()
- {
- int dec,hex[20],n=0;
- cin>> dec;
- for(int i=0;i<200;i++)
- {
- hex[i]=dec%16;
- dec=dec/16;
- n=i;
- if(dec==0)
- {
- break;
- }
- }
- for(int j=n;j>=0;j--)
- {
- if(hex[j]==10)
- {
- cout<<"A";
- }
- if(hex[j]==11)
- {
- cout<<"B";
- }
- if(hex[j]==12)
- {
- cout<<"C";
- }
- if(hex[j]==13)
- {
- cout<<"D";
- }
- if(hex[j]==14)
- {
- cout<<"E";
- }
- if(hex[j]==15)
- {
- cout<<"F";
- }
- if(hex[j]<10)
- {
- cout<<hex[j];
- }
- }
- getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement