0
Write a program in c++ to get a fectorial??
Please help
3 Answers
+ 3
int factorial(int n) {
if (n==1) {
return 1;
}
else {
return n * factorial(n-1);
}
}
int main() {
int n;
cin>>n;
cout << factorial(n);
return 0;
}
0
here is the code
#include<iostream.h>
#include<conio.h>
void main()
{
int i, no, fact=1;
clrscr();
cout<<"Enter the any no. : ";
cin>>no;
for(i=1;i<=no;i++)
{
fact=fact*i;
}
cout<<"Factorial: "<<fact;
getch();
}
0
Thank you