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
What is integer constants?
What does the error 'Null Pointer Assignment' mean and what causes this error?
Is a house a mass structure?
In C language what is a 'dangling pointer'?
How can I find out if there are characters available for reading?
write a c programming using command line argument,demonstrate set operation(eg;union,intersection,difference) example output is c:>setop 12 34 45 1 union 34 42 66 c:>setop 12 34 1 42 66 c:>setop 12 34 diff 12 56 67 78 setop 12 34
What is the right type to use for boolean values in c?
Explain what is the difference between a free-standing and a hosted environment?
Draw a diagram showing how the operating system relates to users, application programs, and the computer hardware ?
Who developed c language and when?
What is an lvalue in c?
What are the types of unary operators?
What are high level languages like C and FORTRAN also known as?
Explain the use of keyword 'register' with respect to variables.
Why static variable is used in c?