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