Ticker

6/recent/ticker-posts

Recursion- DSA C Program

 


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;
	}

Post a Comment

0 Comments