how to add two numbers without using arithmetic operators?

Answer Posted / sanjay bhosale

int x=12382,y=2;
int xor, and, temp;
and = x & y;
xor = x ^ y;

while(and != 0 )
{
and <<= 1;
temp = xor ^ and;
and &= xor;
xor = temp;
}
printf(" sum is : %d",xor);

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

An organised method of depicting the use of an area of computer memory used to signify the uses for different parts of the memory a) swap b) extended memory c) memory map d) all of the above

701


What is the use of #include in c?

568


Find duplicates in a file containing 6 digit number (like uid) in O (n) time.

2602


Is c is a high level language?

613


how to capitalise first letter of each word in a given string?

1424






Why isnt there a numbered, multi-level break statement to break out

582


What could possibly be the problem if a valid function name such as tolower() is being reported by the C compiler as undefined?

739


how many key words availabel in c a) 28 b) 31 c) 32

631


how to make a scientific calculater ?

1558


What is the advantage of an array over individual variables?

729


What is the purpose of type declarations?

673


Can I initialize unions?

585


When c language was developed?

633


What are pointers? What are stacks and queues?

573


Write a program to check whether a number is prime or not using c?

569