there is no error in code.but output is not right.
#include
using namespace std;
int main() {
int n;
cin>>n;
int a[1000];
for(int i=0;i<n;i++){
cin>>a[i];
}
//generate all sub arrays
for(int i=0;i<n;i++){
for(int j=i;j<n;j++){
//elements of subarray(i,j)
for(int k=i;k<=j;k++){
cout<<a[k]<<",";
}
cout<<endl;
}
}
return 0;
}
when input is 1 2 3 4
it gives only 2 as output