Advertisement
Guest User

Untitled

a guest
Apr 21st, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. int main()
  4. {
  5. long long int V;
  6. char hexa[20];
  7. scanf("%lld", &V);
  8. long long int i=0, rem, j, l;
  9. while(V>0)
  10. {
  11. rem = V % 16;
  12. V /= 16;
  13. if(rem<=9)
  14. hexa[i] = rem+48;
  15. else if(rem==10)
  16. hexa[i] = 'A';
  17. else if(rem==11)
  18. hexa[i] = 'B';
  19. else if(rem==12)
  20. hexa[i] = 'C';
  21. else if(rem==13)
  22. hexa[i] = 'D';
  23. else if(rem==14)
  24. hexa[i] = 'E';
  25. else if(rem==15)
  26. hexa[i] = 'F';
  27. i++;
  28. }
  29. hexa[i] = '\0';
  30. l = strlen(hexa);
  31. for(j = l-1; j>=0; j--)
  32. printf("%c", hexa[j]);
  33. printf("\n");
  34. return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement