Creating subaarray

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

    }
    return 0;

}
is there something wrong if i try to enter values in vector using index??beacuse my code worked fine when i used the push_back() function

@khushipriya681 hey khushi there is something issue with the syntax
like In the input loop you have to take an extra variable which take input until loop is running for eg
for(int i=0;i<n;i++)
{
int input;
cin>>input;
v.push_back(input);
}
and you have to declare your vector like vector v;
and next time please follow cb.lk/askdoubt to ask any doubt.

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.