Advertisement
jakaria_hossain

Decimal to Hexa decimal

Oct 23rd, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.28 KB | None | 0 0
  1. #include<stdio.h>
  2. int main()
  3. {
  4. int d,r,i,j=0;
  5. char h[100];
  6. scanf("%d", &d);
  7. while(d>0)
  8. {
  9. r=d%16;
  10. if(r<10) h[j]=48+r;
  11. else h[j]=55+r;
  12. d=d/16;
  13. j++;
  14. }
  15. for(i=j-1;i>=0;i--) printf("%c", h[i]);
  16. return 0;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement