my_put_nbr.c


SUBMITTED BY: Guest

DATE: Nov. 29, 2013, 6:36 p.m.

FORMAT: Text only

SIZE: 317 Bytes

HITS: 1211

  1. int my_put_nbr(int nb)
  2. {
  3. int div;
  4. div = 1;
  5. if (nb < 0)
  6. {
  7. my_putchar(45);
  8. nb = nb * -1;
  9. }
  10. while ((nb / div) >= 10)
  11. div = div * 10;
  12. while (div > 0)
  13. {
  14. my_putchar((nb / div) % 10 + '0');
  15. div = div / 10;
  16. }
  17. }

comments powered by Disqus