Given two numbers N and M. The task to convert both the numbers in the binary form then add respective bits of both the binary converted numbers but with a given condition that there is not any carry system in this addition.
Input: N = 37, M = 12 Output: 41 Input: N = 456, M = 854 Output: 670
If we don’t consider carry then the binary addition of two bits will be:
1 + 0 = 1 0 + 1 = 1 0 + 0 = 0 1 + 1 = 0 (No carry)
- If you observe clearly you will notice that this is just bitwise XOR of two numbers.
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.
- Addition of two numbers without carry
- Count of carry operations on adding two Binary numbers
- Position of rightmost bit with first carry in sum of two binary
- 1 to n bit numbers with no consecutive 1s in binary representation.
- 1 to n bit numbers with no consecutive 1s in binary representation
- Add two numbers without using arithmetic operators
- Convert a given Decimal number to its BCD representation
- XOR counts of 0s and 1s in binary representation
- Check if binary representation of a given number and its complement are anagram
- Largest number with binary representation is m 1's and m-1 0's
- Check if the binary representation of a number has equal number of 0s and 1s in blocks
- Find the number obtained after concatenation of binary representation of M and N
- C program to count zeros and ones in binary representation of a number
- Why Data Structures and Algorithms are "Must Have" for Developers and Where to learn them : Answered
- Binary representation of a given number
- Check if binary representation of a number is palindrome
- Length of the Longest Consecutive 1s in Binary Representation
- Maximum 0's between two immediate 1's in binary representation
- Find longest sequence of 1's in binary representation with one flip
- Find the n-th number whose binary representation is a 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.