Guest User

Untitled

a guest
Dec 10th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int asctohex(char h);
  4.  
  5. int main(){
  6. printf("%d",asctohex('A')); //Passing asctohex any ascii character will give you back the interger HEX value
  7. return 0;
  8. }
  9.  
  10. int asctohex(char h){
  11. if(h == '0'){
  12. return 0;
  13. }
  14. else if(h == '1'){
  15. return 1;
  16. }
  17. else if(h == '2'){
  18. return 2;
  19. }
  20. else if(h == '3'){
  21. return 3;
  22. }
  23. else if(h == '4'){
  24. return 4;
  25. }
  26. else if(h == '5'){
  27. return 5;
  28. }
  29. else if(h == '6'){
  30. return 6;
  31. }
  32. else if(h == '7'){
  33. return 7;
  34. }
  35. else if(h == '8'){
  36. return 8;
  37. }
  38. else if(h == '9'){
  39. return 9;
  40. }
  41. else if(h == 'A'){
  42. return 10;
  43. }
  44. else if(h == 'B'){
  45. return 11;
  46. }
  47. else if(h == 'C'){
  48. return 12;
  49. }
  50. else if(h == 'D'){
  51. return 13;
  52. }
  53. else if(h == 'E'){
  54. return 14;
  55. }
  56. else if(h == 'F'){
  57. return 15;
  58. }
  59. return NULL;
  60. }
Add Comment
Please, Sign In to add comment