Advertisement
diegoaguilar

Dec2Hex

Nov 10th, 2011
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.44 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. int division=1;
  4.  
  5. void conversion (int n)
  6. {
  7. int residuo;
  8. if (division==0) {if ((n%16)!=0) printf("%X", n%16); else; return;}
  9. residuo=n%16;
  10. division=n/16;
  11. conversion(division);
  12. printf("%X", residuo);
  13. }
  14.  
  15. int main ()
  16. {
  17. int n;
  18. system("clear");
  19. printf("\nIngrese un numero decimal: ");
  20. scanf("%d", &n);
  21. printf("\nEl numero en base hexadecimal es 0x");
  22. conversion(n);
  23. printf("\n\n");
  24. return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement