Monday 14 January 2013

Let Us C Chapter 3 problem No: B-b


//Program to find factorial of any number

#include<iostream>

using namespace std;

int main(void)
{
    int i,x=1,n;

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

    for(i=n-1;i>=1;i--)
    {
        n=n*i;
        cout<<i+1<<" x ";
    }
    cout<<'1'<<endl;
      cout<<"Factorial = "<<n;
}

No comments:

Post a Comment

Comments please: