Given an integer N, the task is convert and print the binary equaiva;ent of N.
Input: N = 13
Input: N = 15
Approach Write a recursive function that takes an argument N and recursively calls itself with the value N / 2 as the new argument and prints N % 2 after the call. The base condition will be when N = 0, simply print 0 and return out of the function in that case.
Below is the implementation of the above approach:
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Decimal to binary number using recursion
- Find maximum and minimum element in binary tree without using recursion or stack or queue
- Decimal to binary conversion without using arithmetic operators
- Convert Decimal To Hexa-Decimal including negative numbers
- Operator Overloading '<<' and '>>' operator in a linked list class
- Multiples of 3 and 5 without using % operator
- Divide two integers without using multiplication, division and mod operator | Set2
- Write you own Power without using multiplication(*) and division(/) operators
- Find HCF of two numbers without using recursion or Euclidean algorithm
- Print 1 to 100 in C++, without loop and recursion
- Find power of power under mod of a prime
- Check if given number is a power of d where d is a power of 2
- Compute power of power k times % m
- Larger of a^b or b^a (a raised to power b or b raised to power a)
- Find the sum of power of bit count raised to the power B
- To find sum of two numbers without using any operator
- Program to find remainder without using modulo or % operator
- Division without using '/' operator
- Maximum OR value of a pair in an Array without using OR operator
- Check if any permutation of a number without any leading zeros is a power of 2 or not
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.