program for factorial using recursion - C-Tutorial

Latest

Monday, 26 September 2016

program for factorial using recursion

/* program for factorial using recursion */


#include<stdio.h>
#include<conio.h>
long int rfact(int);
main()
{
int n;
clrscr();
printf("\n Enter n! value: ");
scanf("%d",&n);
printf("\t %d! = %ld",n,rfact(n));
getch();
}

long int rfact(int n)
{
if(n==1)
return n;
else
return n*rfact(n-1);
}

No comments:

Post a Comment