Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int add (int a, int b)
- {
- int c = b & a;
- while (a)
- {
- c = b & a;
- b = b ^ a;
- c <<= 1;
- a = c;
- }
- return b;
- }
- int main (void)
- {
- printf ("1 + 1 is %i.\n", add(1, 1));
- printf ("2 + 2 is %i.\n", add(2, 2));
- printf ("4 + 7 is %i.\n", add(4, 7));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement