You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
302 B
C
18 lines
302 B
C
5 years ago
|
#include<stdio.h>
|
||
|
int fact(int);
|
||
|
int main()
|
||
|
{
|
||
|
int num,f;
|
||
|
printf("\nEnter a number: ");
|
||
|
scanf("%d",&num);
|
||
|
f=fact(num);
|
||
|
printf("\nFactorial of %d is: %d",num,f);
|
||
|
return 0;
|
||
|
}
|
||
|
int fact(int n)
|
||
|
{
|
||
|
if(n==1)
|
||
|
return 1;
|
||
|
else
|
||
|
return (n*fact(n-1));
|
||
|
}
|