Add C example for recursion (#41)

This commit is contained in:
kde0820
2017-11-14 01:11:41 +09:00
committed by Aditya Bhargava
parent 38d50415e8
commit b88af07fd0
3 changed files with 57 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
#include <stdio.h>
void countdown(int i) {
printf("%d\n", i);
// base case
if (i <= 0)
return;
//recursive case
else
countdown(i - 1);
}
int main(void) {
countdown(5);
return 0;
}