Factorial Program in C++
Here we write program to find Factorial Program in C++, you just need basic concept of for loop.
#include<iostream.h>
#include<conoi.h>
using namespace std;
void main()
{
int n,fact=1;
cout<<"Enter any number"<<endl;
cin>>n;
for(;n>0;n--)
{
fact=fact*n;
}
cout<<"Factorial: "<<fact<<endl;
getch();
}
Output:
Enter any number: 5
Factorial: 120
No comments :
Post a Comment