How to add two numbers without using arithmetic operators?
Answer Posted / selloorhari
#include <stdio.h>
int add(int a, int b)
{
if (!a)
return b;
else
return add((a & b) << 1, a ^ b);
}
int main()
{
unsigned int a,b;
printf("Enter the two numbers: \n");
scanf("%d",&a);
scanf("%d",&b);
printf("Sum is: %d",add(a,b));
}
Is This Answer Correct ? | 168 Yes | 30 No |
Post New Answer View All Answers
How to draw the flowchart for structure programs?
What are the functions to open and close file in c language?
Can you please explain the scope of static variables?
Can we change the value of static variable in c?
Which operators cannot be overloaded a) Sizeof b) .* c) :: d) all of the above
What are the c keywords?
What are high level languages like C and FORTRAN also known as?
What are pointers? What are different types of pointers?
What is define c?
What is build process in c?
Compare array data type to pointer data type
What is the difference between pure virtual function and virtual function?
What is integer constants?
In a byte, what is the maximum decimal number that you can accommodate?
What is putchar() function?