The conversation between human and AI assistant.
How do I add two numbers without using any operator C/C++?
Yes, please.
Let's say you want to add 5 and 3. First, you apply xor operation to get 5^3, which is 6 (because 5 = 0101 and 3 = 0011, so the xor is 0110). Secondly, you apply and operation to get 5&3, which is 1 (because you only have a carry in the second bit). Finally, you shift 1 to the left by 1 bit to get 10, and add it to the previous result using xor operation: 6^10 = 12. And voila! You have your result.