difference of two no's with out using - operator

Answer Posted / supri

see subtraction itself is the addition of the number with
its 2's complement....
add(int a,int b)
{
if(!a)
return b;
else
return(add((a&b)<<1,a^b));
}
main()
{
int a,b;
scanf("%d%d",&a,&b);
b=add(~b,1);
printf("%d",add(a,b));
return;
}
u can try this...

Is This Answer Correct ?    2 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is this pointer in c plus plus?

589


How do shell structures work?

563


program for reversing a selected line word by word when multiple lines are given without using strrev

1941


What is the meaning of 2d in c?

607


c program to compute AREA under integral

1804






Why is c used in embedded systems?

606


What is function prototype in c with example?

570


#include int main(){ int i=10; int *ptr=&i; *ptr=(int *)20; printf("%d",i); return 0; } Output: 20 can anyone explain how came the output is 20

1259


What is integer constants?

614


What is meant by preprocessor in c?

526


Explain how do you convert strings to numbers in c?

591


How many types of arrays are there in c?

591


What is the use of parallelize in spark?

570


What are structural members?

566


What does %c do in c?

579