@Mohit: Do you mean

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

Carries normally go to the left, not to the right.

Dave

On Aug 27, 2:28 pm, Mohit kumar lal <[email protected]> wrote:
> int add(int a, int b)
> {
>         if (!a)
>                 return b;
>         else
>                 return add((a & b) >> 1, a ^ b);
>
> }
>
> On Sun, Aug 28, 2011 at 12:54 AM, sagar pareek <[email protected]>wrote:
>
>
>
>
>
> > yeah one option is half adder with "xor" and "and" operators
>
> > one more solution
>
> >http://www.ideone.com/B07bn
>
> > On Sun, Aug 28, 2011 at 12:41 AM, Gaurav Menghani <
> > [email protected]> wrote:
>
> >> I guess you mean without using any 'arithmetic operator'. If yes, it
> >> can be done with XOR and AND operators.
>
> >> Not sure how it can be done otherwise, without using any kind of
> >> operators AT ALL.
>
> >> On Sun, Aug 28, 2011 at 12:37 AM, Brijesh <[email protected]>
> >> wrote:
> >> > How to add two nos without using any operator...?
>
> >> > --
> >> > You received this message because you are subscribed to the Google
> >> Groups
> >> > "Algorithm Geeks" group.
> >> > To view this discussion on the web visit
> >> >https://groups.google.com/d/msg/algogeeks/-/MpNKzlE3UuwJ.
> >> > To post to this group, send email to [email protected].
> >> > To unsubscribe from this group, send email to
> >> > [email protected].
> >> > For more options, visit this group at
> >> >http://groups.google.com/group/algogeeks?hl=en.
>
> >> --
> >> Gaurav Menghani
>
> >> --
> >> You received this message because you are subscribed to the Google Groups
> >> "Algorithm Geeks" group.
> >> To post to this group, send email to [email protected].
> >> To unsubscribe from this group, send email to
> >> [email protected].
> >> For more options, visit this group at
> >>http://groups.google.com/group/algogeeks?hl=en.
>
> > --
> > **Regards
> > SAGAR PAREEK
> > COMPUTER SCIENCE AND ENGINEERING
> > NIT ALLAHABAD
>
> >  --
> > You received this message because you are subscribed to the Google Groups
> > "Algorithm Geeks" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> > [email protected].
> > For more options, visit this group at
> >http://groups.google.com/group/algogeeks?hl=en.
>
> --
> Mohit kumar lal
> rit2009014
> IIIT ALLAHABAD
> contact@9454681805
> [email protected]
> [email protected]
> [email protected]http://profile.iiita.ac.in/rit2009014- Hide quoted text 
> -
>
> - Show quoted text -

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to