Thursday 21 February 2013

Program to compute factorial

| |


#include<iostream>
#include<math.h>

using namespace std;

int main()
{
     int x,i,fact=1;
     cout<<"Enter a number :""\n";
     cin>>x;
     for(i=x;i>0;i--)
     {
                    
                     fact=fact*i;
                     }
                     cout<<" The factorial of "<<x<<" is "<<fact<<".\n";
     system("pause");
     return 0;
         
}
 

Program to compute factorial


Related Posts Plugin for WordPress, Blogger...
Powered by Blogger.