C++ examples for Function:Recursive Function
What does the following program do? Recursive function call
#include <iostream> using namespace std; int mystery( int, int ); int main() /*from ww w. j a v a 2s . c om*/ { int x = 2, y = 3; cout << "The result is " << mystery( x, y ) << endl; } int mystery( int a, int b ) { if ( b == 1 ) // base case return a; else // recursion step return a + mystery( a, b - 1 ); }