how to add numbers without using arithmetic operators.

Answer Posted / sneha

#include <stdio.h>

int add(int a,int b)
{
if(!a)
return b;
else
return add((a&b)<<1,a^b);
}

void main()
{
int a=2, b=3, c;
c = add(a,b);
printf("%d\n",c);
}

Is This Answer Correct ?    15 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why doesn't C support function overloading?

2084


What is void main ()?

779


Which are low level languages?

810


write a proram to reverse the string using switch case?

2651


Tell me is null always defined as 0(zero)?

806






What is the use of getchar functions?

884


What does %d do in c?

704


Tell us bitwise shift operators?

773


Difference between malloc() and calloc() function?

843


"%u" unsigned integer print the a) address of variable b) value of variable c) name of a variable d) none of the above

790


.find the output of the following program? char*myfunc(char*ptr) { ptr +=3; return (ptr); } int main() { char*x,*y; x="HELLO"; y=myfunc(x); printf("y = %s ",y); return 0; }

2272


write a c program to print the next of a particular no without using the arithmetic operator or looping statements?

3471


How many header files are in c?

717


Is there a built-in function in C that can be used for sorting data?

963


What is zero based addressing?

881