Skip to content

Commit b101500

Browse files
recursion demo
1 parent 6790f60 commit b101500

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
3+
#include<bits/stdc++.h>
4+
using namespace std;
5+
6+
void printFun(int test)
7+
{
8+
if (test < 1)
9+
return;
10+
else
11+
{
12+
cout << test << " ";
13+
printFun(test-1); // statement 2
14+
cout << test << " ";
15+
return;
16+
}
17+
}
18+
19+
int main()
20+
{
21+
int test = 3;
22+
printFun(test);
23+
}

0 commit comments

Comments
 (0)