Skip to main content
Write a program to Find Factorial of a number in C++ Language - Program to Find Factorial in C++
Program to Find Factorial of a Number in C++ Language
#include <iostream>
using namespace std;
int main()
{
int n;
int fact = 1;
cout << endl << "Enter a positive number: ";
cin >> n;
if (n < 0)
cout << endl << "Error";
else
{
for(int i = 1; i <= n; ++i)
{
fact *= i;
}
cout << endl << "Factorial of " << n << " = " << fact << endl;
}
return 0;
}
इस कोड को हमने CODEBLOCK पर बना कर run किया है
Comments
Post a Comment