0

Write a program in c++ to get a fectorial??

Please help

5th Dec 2016, 7:02 AM
Akshit Kanaujia
Akshit Kanaujia - avatar
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; }
5th Dec 2016, 12:54 PM
Rishabh Agrawal
Rishabh Agrawal - avatar
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(); }
5th Dec 2016, 7:18 AM
Mahesh BudhaThoki
Mahesh BudhaThoki - avatar
0
Thank you
5th Dec 2016, 7:25 AM
Akshit Kanaujia
Akshit Kanaujia - avatar