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 a program be made to print the name of a source file where an error occurs?
What is sizeof int?
What are the 4 types of unions?
Explain the use of 'auto' keyword in c programming?
What is a file descriptor in c?
If jack lies on Mon, Tue Wed and jill lies on Thursday, Friday and Saturday. If both together tell they lied yesterday. So c the given options and then c cos in the given dates one will be saying the truth and one will be lying. I got Thursday as option because jack is saying the truth he lied yest but jill is lying again as he lies on that day.
What is wrong with this code?
Explain the concept and use of type void.
Which is the memory area not included in C program? give the reason
Why can't I perform arithmetic on a void* pointer?
What is function and its example?
what is ur strangth & weekness
How can I prevent another program from modifying part of a file that I am modifying?
What are the different types of control structures in programming?
What is the value of a[3] if integer a[] = {5,4,3,2,1}?