C++/CLI Example: Recursion |
|
A recursive function is a function that calls itself. Here is an example of such a function, including how to call it: #include <cmath> using namespace std; using namespace System; void Show(int Number) { if( Number > 0 ) { Console::WriteLine(L"Number: {0}", Number); Number--; Show(Number); } } int main() { const double Nbr = 12.48; const double SquareRoot = sqrt(Nbr); Console::WriteLine(L"Square Root of {0} = {1}", Nbr, SquareRoot); Console::WriteLine(L""); Show(14); return 0; }
|
|
||
Home | Copyright © 2006-2016, FunctionX, Inc. | |
|