Toggle navigation
Home
Latest pastes
FAQ
Random
Register
Login
Example Program For Factorial Value Using Function In C++
SUBMITTED BY:
Nrupeshsinh
DATE:
June 24, 2016, 8:25 a.m.
FORMAT:
Text only
SIZE:
637 Bytes
Raw
Download
Tweet
HITS:
605
Go to comments
Report
#include<iostream>
#include<conio.h>
using namespace std;
//Function
long factorial(int);
int main()
{
// Variable Declaration
int counter, n;
// Get Input Value
cout<<"Enter the Number :";
cin>>n;
// Factorial Function Call
cout<<n<<" Factorial Value Is "<<factorial(n);
// Wait For Output Screen
getch();
return 0;
}
// Factorial Function
long factorial(int n)
{
int counter;
long fact = 1;
//for Loop Block
for (int counter = 1; counter <= n; counter++)
{
fact = fact * counter;
}
return fact;
}
Please enable JavaScript to view the
comments powered by Disqus.
comments powered by
Disqus