Qualcomm Interview Question

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

Interview Answers

Anonymous

Jun 13, 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

Aug 6, 2014

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

1

Anonymous

Jun 18, 2012

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

Anonymous

Jun 2, 2012

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

1