Qualcomm interview question

Write a program in C to add two numbers without using any maths operator (+, -, /, *).

Interview Answers

Anonymous

13 Jun 2012

int sum(int x, int y) { if( x == y) return (x << 1); else return (x ^ y); } see complete program at http://www.ssiddique.info/add-two-numbers-without-using.html

4

Anonymous

6 Aug 2014

The method is to make use of binary addition using logical statements

1

Anonymous

18 Jun 2012

int a, b,result; printf(:enter any two numbers to add"); scanf("%d%d",&a,&b); result=add(a,b);

Anonymous

2 Jun 2012

int a,b,ans; a=2; b=3; if (a==2 && b==3) ans=5;

1