Skip to content

Instantly share code, notes, and snippets.

@timothyandrew
Created April 16, 2013 07:07
Show Gist options
  • Save timothyandrew/5393960 to your computer and use it in GitHub Desktop.
Save timothyandrew/5393960 to your computer and use it in GitHub Desktop.
void swap(int a, int b, int* ref1, int* ref2) {
*ref2 = a;
*ref1 = b;
}
int subtract(int a, int b) {
if(b == 0) return a + 1;
return a + subtract(a, b - 1);
}
int main() {
int a = 5, b = 10;
swap(a, b, &a, &b);
printf("%d\n%d\n", a,b);
printf("%d\n", subtract(a,b));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment