Garbsge value and segmentation error

why is the following code giving me the garbage value,
and when i am initializing the brr[] then it is giving the "segmentation error "

kindly explain

#include
#include
using namespace std;
int bitonic(int arr[],int n)
{
int inc[n];
int dec[n];
int Max;
inc[0]=0;
dec[n-1]=0;
for(int i=1; i>=0; i–)
{
inc[i]=(arr[i]>arr[i-1])?inc[i-1]+1:1;
}
for(int i=n-2; i<n; i++)
{
inc[i]=(arr[i]>arr[i+1])?inc[i+1]+1:1;
}
Max =inc[0]+dec[0]-1;
for(int i=0; i<n; i++)
if(inc[i]+dec[i]-1 >Max)
Max = inc[i]+dec[i]-1;
return Max;

}

int main()
{
int n;
cin>>n;

int drr[1000];
int Array_sum=0;
for(int i = 0; i<n; i++)
{
    int New;
    int arr[New+1000];

    cin>>New;
    for(int j=0; j<New; j++)
    {
        cin>>arr[j];

    }




    drr[i]=bitonic(arr,New);


}





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


return 0;

}

hello @saurabh66
first read new and then declare ur array
image

@aman212yadav thank.
but still it is giving garbage as final answer. plz check

pls save ur code here->https://ide.codingblocks.com/
and sharew thee link with me

image
check these conditons .
it is not correct.

for first one it should be i=0

i don’t feel there is any issue in that .
can you please correct my code by commenting next there.

i guess the changes that you are making not getting saved.

checck this-> https://ide.codingblocks.com/s/281137

ok. i got it .
thanks a lot!!

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.