C Program to find Factorial of a number using Functions

#include<stdio.h>
#include<conio.h>
int fact(int);
int main()
{
 int x,g;
 clrscr();
 printf("Enter Number:- ");
 scanf("%d",&x);
 g= fact(x);
printf("Factorial of Number is:- %d",g);
getch();
}
int fact(int y)
{
 int i, f=1;
 for(i=y;i>=1;i--)
  {
   f=f*i;
  }
  return (f);
}

OUTPUT:-

factorial

Leave a Reply

Your email address will not be published. Required fields are marked *