Created
April 16, 2013 07:23
-
-
Save timothyandrew/5394047 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int add(int a, int b) { | |
if(b == 0) return a; | |
return 1 + add(a, b - 1); | |
} | |
int subtract(int a, int b) { | |
if(b == 0) return a; | |
return subtract(a, b - 1) - 1; | |
} | |
int main() { | |
int a = 5, b = 10; | |
a = add(a,b); | |
b = subtract(a,b); | |
a = subtract(a,b); | |
printf("%d\n%d\n", a,b); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment