Friday, 5 July 2013

Write a program to two show Factorial of a number

#include<iostream.h>
int rec(int);
main()
{
    int a ,fact;
    cout<<"enter any number";
    cin>>a;
    fact=rec(a);
    cout<<fact;
}
int rec(int x)
{
    int f;
    if (x==1)
    return(1);
    else
    f=x*rec(x-1);
    return(f);
}

No comments:

Post a Comment