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