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);
}

Comments

Popular posts from this blog

Write a program to add two number using inline function in C++?

Traversing of elements program with algorithm and Flowchart