Factorial Number
#include<stdio.h>
#include<conio.h>
Int fact(int);
void main()
{
Int s,n;
Clrscr();
Printf ("enter the number");
Printf("%d",&n);
s=fact(n);
Printf("The factorial is %d",s);
getch();
}
Int fact(int n)
{
Int f;
if(n==1)
{
return 1;
}
Else
{
f=n*fact(n-1);
return f;
}
}
Output:
Enter the number
5
The factorial is 120
#include<conio.h>
Int fact(int);
void main()
{
Int s,n;
Clrscr();
Printf ("enter the number");
Printf("%d",&n);
s=fact(n);
Printf("The factorial is %d",s);
getch();
}
Int fact(int n)
{
Int f;
if(n==1)
{
return 1;
}
Else
{
f=n*fact(n-1);
return f;
}
}
Output:
Enter the number
5
The factorial is 120
👍🏻
ReplyDeletenice
ReplyDelete