Skip to content

Commit dd959a9

Browse files
authored
Add recursion
1 parent 20e9dc1 commit dd959a9

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

recursion.cpp

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// A C++ program to demonstrate working of recursion
2+
// https://www.geeksforgeeks.org/recursion/
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);
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)