c programming tips and tricks

Add Any Numbers without “+” Operator

Bitwise operators can be used to perform the addition (+) operation as mentioned in below example:

int Add(int x, int y)
	if (y == 0)
		return x;
		return Add( x ^ y, (x & y) << 1);

Leave a Reply

Your email address will not be published. Required fields are marked *