| |
GeekInterview.com > Interview Questions > Programming > C
| Print | |
Question: Sum of two numbers without using arithmetic operators
Answer: ex: int a=10; int b=10; int sum=a+b; without using "+" operator calculate sum |
| August 08, 2008 00:36:04 |
#7 |
| shiva chitta |
Member Since: August 2008 Total Comments: 1 |
RE: sum of two numbers without using arithmetic operators |
#include add(int a,int b) { if(!a) return b; else return add((a&b)<<1,a^b); } void main() { int a=2, b=5,c; c= add(a,b); cout<<c; }
hope it 'll help you right........... |
| |
Back To Question | |