C Program code to find the factorial of a number


This program finds the factorial of a number and we have created a function called facto to do this.



#include<stdio.h>
int facto(int f)
{
int fact = 1;
for(;f>0;f--)
{
fact=fact*f;
}
return fact;
}
int main()
{
int n,fact;
printf("Enter the number to find the factorial: ");
scanf("%d",&n);
fact = facto(n);
printf("The factorial of %d is %d ",n,fact);
getch();
return(0);
}
view raw gistfile1.txt hosted with ❤ by GitHub

Comments