This is the program for Recursion in C. Here we are gonna find the factorial of a number through Recursion.
#include<stdio.h> int factorial(int x){ if(x>=1){ return x*factorial(x-1); } else{ return 1; } } int main(){ int x; printf("enter the no. for recursion : "); scanf("%d",&x); printf("factorial is : %d",factorial(x)); return 0; }
0 Comments