#include
void main()
{
float fact(float),f;
clrscr();
printf("\nEnter the number whose factorial is to be found out\n");
scanf("%f",&f);
printf("\nThe factorial of %f is %f.",f,fact(f));
getch();
}
float fact(float no)
{
float factorial;
if(no==1)
return 1;
else
factorial=no*fact(no-1);
return factorial;
}
No comments:
Post a Comment