#include int main() { unsigned int t = 0xffffffff; unsigned int z = 1; int a = 10, b = 10, sum = 0, r = 0; while (t) { int t1, t2; t1 = a & 0x00000001; t2 = b & 0x00000001; if ((t1 ^ t2 ^ r) == 1) { if (t1 == 1 && t2 == 1 && r == 1) r = 1; else r = 0; sum = sum | z; } else { if (t1 == 0 && t2 == 0 && r == 0) r = 0; else r = 1; } a >>= 1; b >>= 1; z <<= 1; t >>= 1; } printf("sum: %dn", sum); return 0; }
Sum of two numbers without using arithmetic operators
int a=10;
int b=10;
int sum=a+b;
without using "+" operator calculate sum
Questions by meda_reddy
Editorial / Best Answer
jintojosvoid main()
{
int a=10,b=20;
while(b--) a++;
printf("Sum is :%d",a);
}
Related Answered Questions
Related Open Questions