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 can I display a percentage-done indication that updates itself in place, or show one of those twirling baton progress indicators?
What do you know about the use of bit field?
What is size of union in c?
What are Macros? What are its advantages and disadvantages?
Is swift based on c?
How can I automatically locate a programs configuration files in the same directory as the executable?
What is c programing language?
Is javascript based on c?
What is a nested loop?
What is array of structure in c programming?
What is the use of sizeof () in c?
Can a variable be both const and volatile?
Function which gives a pointer to a binary trees const an integer value at each code, return function of all the nodes in binary tree.?
all c language question
What are external variables in c?