/bin/run.sh: line 4: 18 Segmentation fault (core dumped) ./exe

I am getting Segmentation error in this code

Link To Code-> https://ide.codingblocks.com/s/476340

line 33 34:

int n=sizeof(prices)/sizeof(int);
int span[n+1]={0};

Now not getting error but wrong answer
Correct answer should be 1 1 1 2 1 4 6