Educational Blog: Non recursive Function to compute n!

Sunday, 15 February 2015

Non recursive Function to compute n!

#include<stdio.h>
#include<conio.h>
Long factorial(int);
void main()
{
   int n;
   long fact=1;
   clrscr();
   printf("enter no");
   scanf("%d",&n);
   fact=factorial(n);
   printf("Factorial is %ld ",fact);
   getch();
}
long factorial(int n)
{
int i;
Long fact;
   for(i=1;i<=n;i++)
   {
               fact=fact*i;
   }

}

No comments:

Post a Comment