Showing error in coding blocks ide

terminate called after throwing an instance of ‘std::bad_array_new_length’
what(): std::bad_array_new_length
/bin/run.sh: line 4: 18 Aborted (core dumped) ./exe

#include
using namespace std;

int main() {

int n;
cout<<"enter the asize of an array\n";

cin>>n;

int * a= new int[n]{0};
cout<<“enter the elements\n”;
for(int i=0;i<n;i++)
{
cin>>a[i];
}

for(int i=0;i<n;i++)
{
    cout<<a[i]<<" ";
}

delete [] a;

return 0;
}

every thing is working fine with me, try again to run the code
if you have further doubt feel free to ask

reference code:

ok i got it sorry i was using in a wrong way

don’t worry,
keep learning and go ahead

if you doubt is resolved, plz mark it as resolved from your side

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.