ciabatta/test/test_assert.c

13 lines
265 B
C
Raw Permalink Normal View History

2022-06-16 12:36:35 +00:00
#include <assert.h>
2022-06-19 05:24:36 +00:00
2022-07-28 18:46:13 +00:00
int factorial(int n) {
assert(n >= 0);
if(n == 0) return 1;
return n*factorial(n-1);
2022-06-19 05:24:36 +00:00
}
2022-06-16 12:36:35 +00:00
int main() {
2022-07-28 18:46:13 +00:00
printf("Factorial of %d is %d\n", 10, factorial(10));
printf("Factorial of %d is %d\n", -1, factorial(-1));
return 0;
}