EmbLogic's Blog

Write a program to find the factorial using recursion?

CODE :

#include<stdio.h>
#include<stdlib.h>
int fact (int );
int main()
{
int n;
printf(“Enter number whose factroialu want u find\n”);
scanf(“%d”,&n);
printf(“Factorial of %d is %d\n”,n,fact(n));
return 0;
}

int fact( int n )
{
if(n!=1)
return n*fact(n-1);
}

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>