I have to add 1 to a number in C. I have to do this without arithmetic operators like '+', '++', .. so on.
I have written following line of code.
int a = 1234;
int b = 1;
printf("%d", a ^ b);
This works fine till the integer limit is reached i.e., for 32 bit it is 4294967295. But I see in many other websites that to perform the same they do AND of two numbers, followed by XOR and left shift.
Please suggest whether my approach is correct as I am novice in C.