Alternate Code for Subarray in C++

Sir, Is there any other code (other than the given in the lecture) through which we can find the subarray of an array? If it is, Can you please tell me?

Can you be more specific about the problem ?

Sir,is there any other way to write the subarray code means that we can devise any other logic that can print subarray of an array?

You mean , code for printing subarrays ?

Yes,sir.If it is available can you please tell me?

Printing all subarrays will cost O(n3) time. We can’t optimise it for priinting all subarrays as we have to go through all subarrays. So, just use brute force approach
for(int i=0;i<n;i++){
for(int j=i;j<n;j++){
// Printing subarray from i to j
for(int k=i;k<=j;k++) cout<<a[k]<< " ";
cout<<endl;
}
}