Recursion is a programming technique where a function calls itself to solve a problem. It is commonly used to solve problems like calculating factorials, Fibonacci numbers, etc.
#includeint factorial(int n) { if (n == 0) { return 1; } else { return n * factorial(n - 1); } } int main() { int result = factorial(5); printf("Factorial of 5 is: %d\n", result); return 0; }
This program calculates the factorial of a number using recursion.