Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Napisz program, w którym zdefiniujesz funkcję rekurencyjną konwertującą zapis dziesiętny liczby naturalnej większej od zera na zapis szesnastkowy.
- */
- #include <stdio.h>
- void convert_to_hexadecimal(unsigned long int number)
- {
- if(number == 0) return;
- convert_to_hexadecimal(number/16);
- number %= 16;
- switch (number) {
- case 10: printf("A"); break;
- case 11: printf("B"); break;
- case 12: printf("C"); break;
- case 13: printf("D"); break;
- case 14: printf("E"); break;
- case 15: printf("F"); break;
- default: printf("%lu", number);
- }
- }
- int main(void)
- {
- convert_to_hexadecimal(999);
- printf("\n");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement