Hyluss

Convert To Binary

Dec 5th, 2017
288
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.32 KB | None | 0 0
  1. void decToBinary(int);
  2.  
  3. int main()
  4. {
  5.     int number;
  6.  
  7.     printf("Enter number to convert to binary: ");
  8.     scanf("%d", &number);
  9.    
  10.     decToBinary(number);
  11.     return 0;
  12. }
  13.  
  14. void decToBinary(int num)
  15. {
  16.     if (num == 0)
  17.     {
  18.         return ;
  19.     }
  20.  
  21.     decToBinary(num / 2);
  22.     printf("%d", num % 2);
  23. }
Advertisement
Comments
  • User was banned
Add Comment
Please, Sign In to add comment