#include<stdio.h>
#include<conio.h>
int fact(int n)
{
int f;
if(n==0)
return 1;
else
f=n*fact(n-1);
return f;
}
void main()
{
int n,f;
clrscr();
printf("\n Enter the value of n");
scanf("%d",&n);
f=fact(n);
printf("\n Factorial of %d is %d ",n.f);
getch();
}
OUTPUT
Enter the value of n 5
Factorial of 5 is 120
#include<conio.h>
int fact(int n)
{
int f;
if(n==0)
return 1;
else
f=n*fact(n-1);
return f;
}
void main()
{
int n,f;
clrscr();
printf("\n Enter the value of n");
scanf("%d",&n);
f=fact(n);
printf("\n Factorial of %d is %d ",n.f);
getch();
}
OUTPUT
Enter the value of n 5
Factorial of 5 is 120
No comments:
Post a Comment