Advertisement
Guest User

Save me

a guest
Apr 9th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. 1 #include<stdio.h>
  2. 2 #include<string.h>
  3. 3 int main(void)
  4. 4 {
  5. 5 char base_digits[16] =
  6. 6 {'0', '1', '2', '3', '4', '5', '6', '7',
  7. 7 '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
  8. 8 char *lastdigit = "F";
  9. 9 int converted_number[64];
  10. 10 long int number_to_convert;
  11. 11 int next_digit, base, index=0;
  12. 12 number_to_convert=12345;
  13. 13 base=5;
  14. 14 while (number_to_convert != 0)
  15. 15 {
  16. 16 converted_number[index] = number_to_convert % base;
  17. 17 number_to_convert = number_to_convert / base;
  18. 18 ++index;
  19. 19 *lastdigit = 'E';
  20. 20 }
  21. 21 --index;
  22. 22 printf("\n\nConverted Number = ");
  23. 23 for( ; index>=0; index--)
  24. 24 {
  25. 25 printf("%c", base_digits[converted_number[index]]);
  26. 26 }
  27. 27 }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement