img
Question:
Published on: 21 November, 2024

Write a C program to find factorial(using recursion) of any no.

Answer:

 

#include<stdio.h>
#include<conio.h>
int fact(int);
main()
{
	int n,result;
	printf("\n Enter any number");
	scanf("%d",&n);
	result=fact(n);
	printf("\n The result=%d",result);
	getch();
}
int fact(int m)
{
	if(m==0)
	 return 1;
	else
	 return(m*fact(m-1)); 
}

 

Output:

Random questions