Given two integers M and N the task is to find the number formed by concatenating the binary equivalents of M and N i.e. M + N.
Input: M = 4, N = 5
Binary equivalent of 4 is 100 and for 5 it is 101
after concatenation, the resultant binary number
formed is 100101 whose decimal equivalent is 37.
Input: M = 3, N = 4
Approach: Convert both the numbers M and N into there binary equivalents then concatenate these numbers as M + N and print the decimal equivalent of the resulting binary number formed after concatenation.
Below is the implementation of the above approach:
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Find the n-th number whose binary representation is a palindrome
- Find consecutive 1s of length >= n in binary representation of a number
- Find the occurrence of the given binary pattern in the binary representation of the array elements
- Find i’th index character in a binary string obtained after n iterations | Set 2
- Find i'th Index character in a binary string obtained after n iterations
- Find value of k-th bit in binary representation
- Binary representation of a given number
- Binary representation of next number
- Count number of trailing zeros in Binary representation of a number using Bitset
- Check if the binary representation of a number has equal number of 0s and 1s in blocks
- Largest number with binary representation is m 1's and m-1 0's
- Next greater number than N with exactly one bit different in binary representation of N
- Binary representation of previous number
- Find next greater element with no consecutive 1 in it's binary representation
- Find longest sequence of 1's in binary representation with one flip
- Number of leading zeros in binary representation of a given number
- Prime Number of Set Bits in Binary Representation | Set 1
- Prime Number of Set Bits in Binary Representation | Set 2
- Occurrences of a pattern in binary representation of a number
- Check if binary representation of a number is palindrome
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.