C program to calculate factorial using "function".
/*C program to calculate factorial using "function".*/
#include <stdio.h>
#include <conio.h>
void main()
{
int n,x;
int fun(int);
printf("Enter any no=");
scanf("%d",&n);
x=fun(n);
printf("factorial of %d is %d ",n,x);
getch();
}
fun(int z)
{int fact=1;
for(;z!=0;z--)
{ fact*=z ;
}
return(fact);
}
Expected Output:
Enter Enter any no=5
Factorial of 5 is=120