Open Source Your Knowledge, Become a Contributor

Technology knowledge has to be shared and made accessible for free. Join the movement.

Create Content

Recursion - Part I

So far, we have seen examples of main calling other functions. It's possible for any function to call another; for example:

using namespace std;
void bar() {
cout << "bar" << endl;
void foo() {
cout << "foo" << ' ';
int main() {
// enter foo and print "foo", then enter bar and print "bar"
return 0;
Open Source Your Knowledge: become a Contributor and help others learn. Create New Content