Advertisement
AshfaqFardin

Practice Problem (Decimal to Binary)

Aug 25th, 2021
1,527
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. // Decimal to binary conversion
  5. // using recursion
  6. int find(int decimal_number)
  7. {
  8.     if (decimal_number == 0)
  9.         return 0;
  10.     else
  11.         return (decimal_number % 2 + 10 *
  12.                 find(decimal_number / 2));
  13. }
  14.  
  15. // Driver code
  16. int main()
  17. {
  18.     int decimal_number = 10;
  19.     cout << find(decimal_number);
  20.     return 0;
  21. }
  22. // This code is contributed by shivanisinghss2110
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement