Subsequences for Contigious

how to generate contigous subsequences?
like example for 1 2 3
1
2
3
1 2
2 3
1 2 3

@archa_1712
hello Yogendra,
it simple ->
use two loops
for(int i=0 ; i<n;i++){
for(int j=i;j<n;j++){
print numbers from index i to index j
}

}

it will take three loops

Is there any optimised approach??

@archa_1712
no there is not any optimised approach

#include
using namespace std;
int main() {
int a[]={1,2,3};
int n=sizeof(a)/sizeof(int);
for(int i=0;i<n;i++)
{
for(int j=i;j<n;j++)
{
int A = i;
int B = j;
while(A<=B)
{
cout<<a[A]<<" ";
A++;
}
cout<<endl;
}

}

}

So it will be like this?..Using Three loops?

@archa_1712
correct . . . . . :+1::+1:

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.