Monday, 23 February 2015

Recursive Function in C


/*
Recursive Function

A Function can Call Iteself Regularly is known as Recursive Function

*/
#include<stdio.h>
#include<conio.h>
main()
{
int n;
clrscr();
printf("\n Enter Number To Find Factorial\n");
scanf("%d",&n);
printf("\n Factorial Of Given Number is :%d",fact(n));
getch();
}
int fact(int n)
{
int fa;
if(n==0)
return 1;
else
fa=n*fact(n-1);
return fa;
}

No comments:

Post a Comment