Use of return statement

sir, In void Subsequence function what is the use return ,where its returning
code:
using namespace std;
#include
void print_subsequence(int out[],int j)
{
cout<<"{";
for(int i=0;i<j;i++)
cout<<out[i];
cout<<"}\n";
}
void subsequence(int in[],int out[],int i,int j,int n)
{
//base case
if(i==n)
{
print_subsequence(out,j);
return; //???
}

//Rec case
//1. Include the current element
out[j]=in[i];
subsequence(in,out,i+1,j+1,n);
//2. Exclude the current Element
subsequence(in,out,i+1,j,n);

}
int main()
{
int t;
cin>>t;
while(t–)
{
int n;
cin>>n;
int in[n],out[n];

	for(int i=0;i<n;i++)
	cin>>in[i];
	
	subsequence(in,out,0,0,n);
}

}

hello @n.nishchaya2000
The return statement stops execution and returns to the calling function. When a return statement is executed, the function is terminated immediately at that point, regardless of whether it’s in the middle of a loop, etc…
so here when we hit our base case ie i==n we print our subsequence and using return we terminate this function call and return the control to the calling function

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.