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
Is it better to use malloc() or calloc()?
Is javascript written in c?
What is a protocol in c?
any "C" function by default returns an a) int value b) float value c) char value d) a & b
Write a progarm to find the length of string using switch case?
What is null in c?
Describe the order of precedence with regards to operators in C.
Tell us bitwise shift operators?
What is the difference between text files and binary files?
What is difference between %d and %i in c?
What is the difference between new and malloc functions?
What is strcpy() function?
i have a written test for microland please give me test pattern
What is "Hungarian Notation"?
Where are local variables stored in c?