Generating subarrays

#include
using namespace std;
int main(){
int n;
int a[1000];
cin>>n;
for(int i=0;i<n;i++){
cin>>a[i];
for(int i=0;i<n;i++){
for(int j=i;j<n;j++){
for(int k=i;k<=j;k++){
cout<<a[k]<<" ";
}
cout<<endl;
}
}
}
}

https://ide.codingblocks.com/s/162288 this is the ide of the code

You are getting unexpected zero because you have not closed the for loop in which you are taking inputs from user.

Your corrected code :