#include<stdio.h>
#include<conio.h>
void main()
{
int i,fact=1,n;
clrscr();
printf("\nEnter the no of terms =");
scanf("%d",&n);
for(i=1;i<=n;i++)
fact*=i;
printf("\nFactorial value for %d terms = %d",n,fact);
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int fact(int);
int a,b,c,n,r;
clrscr();
printf("Enter values of n and r \n");
scanf("%d%d",&n,&r);
a=fact(n);
b=fact(r);
c=fact(n-r);
printf("Output=%2f \n",a\(b*c));
getch();
}
int fact(int n)
{
int(n==1)
return 1;
else
f=n*(fact*(n-1));
return f;
}
Quite a popular question, it is the 7th time I answer it;)
int fact (int n)
{
if (n<=1) return 1;
else return n*fact(n-1);
}