Guest User

Untitled

a guest
Feb 20th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.25 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. /**
  4. * Hexadecimal number to integer
  5. */
  6. static int c2n(int c) {
  7. return c - (c&64?:87:48);
  8. }
  9.  
  10. int main(void) {
  11. char c;
  12.  
  13. printf("Enter hexadecimal number: ");
  14. scanf("%c", &c);
  15. printf("%d\n", c2n(c));
  16.  
  17. return 0;
  18. }
Add Comment
Please, Sign In to add comment