Write a program to calculate the factorial of any number
Calculate the Factorial Of Any Number
Object: Write a program to calculate the factorial of any number. C++ Projects.
Code:
#include<iostream>
#include<conio.h>
using namespace std;
void main()
{
int i,no,fact=1;
cout<<” Enter Any Number: “;
cin>>no;
for(i=no;i>=1;i–)
{
fact=fact*i;
}
cout<<“\n Factorial of given Number is: “<<fact;
getch();
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | #include<iostream> #include<conio.h> using namespace std; void main() { int i,no,fact=1; cout<<" Enter Any Number: "; cin>>no; for(i=no;i>=1;i--) { fact=fact*i; } cout<<"\n Factorial of given Number is: "<<fact; getch(); } |