Monday 8 April 2013

Find factorial of a number using recursion c++




#include <cstdlib>

#include <iostream>
using namespace std;
int fact(int a)
{
   if(a==1)
   return 1;
   else
   return a*fact(a-1);  
}
int main(int argc, char *argv[])
{ 
    int number;
    int call;
    cout<<"-----------------------------------"<<endl;
    cout<<"insert a number to find factorial:"<<endl;
    cout<<"-----------------------------------"<<endl;
    cin>>number;
    call=fact(number);
    cout<<"----------------"<<endl;
    cout<<"factorial will:";
    cout<<call<<endl;
    cout<<"----------------"<<endl;
    system("PAUSE");
    return EXIT_SUCCESS;
}

c++ test

c++ recursive functions

1 comments:

Anonymous said...

'youtube' vr fishing videos - VCR - Videoodl.cc
[youtube] vr youtube to mp3 download fishing videos | Videoodl.cc

Post a Comment