Write a program to add two numbers without using arithmetic operators. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 1

Write a program to add two numbers without using arithmetic operators.

You have to take two numbers from user and calculate the sum. Actually i have to know how the bitwise operators work in this program. I couldn't able to understand the working over XOR AND & << op.

7th Apr 2020, 8:59 AM
AJAY KUMAR
AJAY KUMAR - avatar
1 Answer
+ 1
You first need to know bit representations of integers. Then you can do the rest. If you do know, then you can try doing something like that. For example take two numbers. Like 34 and 20. Sum them up. Then try to find a relationship between the result and those two numbers. And try to find how you can achieve this.
7th Apr 2020, 9:33 AM
Mustafa K.
Mustafa K. - avatar