C++ Programming Tutorial

 
 
 
 

Image

 #include <iostream.h>
 #include    <conio.h>

  const long factorial(const long);


 int main( )
 {
    clrscr( );

    int n;

    cout<<\"\\n Enter the number = \";
    cin>>n;

    cout<<\"\\n n! = \"<<n<<\"!\"<<\"  =  \"<<factorial(n)<<endl;

    getch( );
    return 0;
 }



 //--------------------------  factorial( )  -----------------------------//


 const long factorial(const long n)
 {
    long fn=1;

    if(n>1)
       fn=(n*factorial(n-1));

    return fn;
 }