Skip to content
This repository was archived by the owner on Oct 1, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions Language/C++/Factorial.cpp

This file was deleted.

22 changes: 22 additions & 0 deletions Language/C++/Factorialwithoutrecursion.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*This program accepts a integer variable as an input, calculates its factorial and then displays the result as output without recursion^/

#include<iostream>
using namespace std;
long int fact(int);
int main()
{
int n;long int result;
cout<<"Enter a number ";
cin>>n;
result=fact(n);
cout<<"The factorial of the number "<<n<<" is "<<result;
return 0;
}
long int fact(int n)
{ long int p=1;
for(int i=1;i<=n;i++) //used to find the factorial of number n
{
p=p*i;
}
return p;
}