0% found this document useful (0 votes)
13 views1 page

L6 Fact Recursion

Uploaded by

shreeumaluti
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views1 page

L6 Fact Recursion

Uploaded by

shreeumaluti
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

6) To compute factorial of an input number using recursive function.

/* To compute factorial of an input number using recursive function */


#include <stdio.h>
int main()
{
int n, fact;
/* Function declaration*/
int find_fact(int m);
printf("factorial of N using recursive function: \n");
/* Accepting input */
printf("Enter an integer :\n");
scanf("%d",&n);
if(n<0)
printf("Negative no: factorial not defined!");
else
{
/* Function call*/
fact=find_fact(n);
printf("Factorial = %d",fact);
}
}

/* Recursive Function definition*/


int find_fact(int m)
{
if(m==0)
return(1);
else
return(m*find_fact(m-1));
}

You might also like