PDA

View Full Version : How to Write a function factorial in C++ and java and php 2011



Xpert
05-12-2011, 09:14 PM
"Write a function factorial, which calculates the factorial of an integer. "
#include <iostream>
using namespace std;

int factorial (int x);

int main ()
{

int n;
cout<<"Enter number: ";
cin>>n;

int fact;

fact = factorial(n);

cout<<"The factorial of number: "<<n<<" is: "<<fact<<endl;

cin.get(); cin.get();
return 0;
}

int factorial(int x)
{

int i;
int F=1;

for (i = 1; i <= x; i++)
F*=i;

return F;
}

dawoodasad17
05-12-2011, 10:02 PM
dear friend
i am new on internet want some help
i visit a website sleek sight dot com its provied me free website but i don't
know to make a designing can any one tell how i can make a free website update and
designing i am very thankful to u for your convinece