Advertisement
Joao_Joao

Questão 259 Lista de Exercícios IFPB

May 21st, 2022
974
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.   -- HEXADECIMAL --
  3.   INPUT: 30
  4.   OUTPUT: 1E
  5. */
  6.  
  7. #include <stdio.h>
  8.  
  9. void hex(int n) {
  10.   if(n < 1) return;
  11.   hex(n / 16);
  12.   int r = n % 16;
  13.   if(r < 10) printf("%d", r);
  14.   else printf("%c", r+55);
  15. }
  16.  
  17. void main() {
  18.   int n;
  19.   scanf("%d", &n);
  20.   printf("Valor correspondente em hexadecimal: ");
  21.   hex(n);
  22.   printf("\n");
  23. }
  24.  
Advertisement
RAW Paste Data Copied
Advertisement