what is wrong wid my code?

#include<stdio.h>
int count_negative(int* ,int);
int main()
{
int x,n,i,count,cost=0;
scanf("%d",&n);
int arr[n];
for(i=0;i<n;i++)
scanf("%d",&arr[i]);
scanf("%d",&x);
count=count_negative(arr , n);
while(count!=0)
{
if(count>1)
{
for(i=0;i<n;i++)
arr[i]=arr[i]+1;
cost=cost+x;
}
else
{
for(i=0;i<n;i++)
if(arr[i]<0)
arr[i]=arr[i]+1;
cost=cost+1;
}
count=count_negative(arr , n);
}
printf("%d\n",cost);
return 0;
}
int count_negative(int *arr, int n)
{
int i,k=0;
for(i=0;i<n;i++)
if(arr[i]<0)
k++;
return(k);
}

impossible to read yr code…give links to yr solution and the problem…

array size should be given.You have given it as a variable n, but the compiler doesn’t know the value of n that it would get as input, to create a array and this creates a problem to compile. So, the above code gives compilation error. Use “malloc” and other functions to implement the dynamic allocation for array. Or, you can give a static allocation by declaring a large size array and using n locations out of it.

this code is not giving any compilation error…infact it is running correctly for all the test cases …but codechef isn’t accepting it!

INTEG Problem - CodeChef this the problem statement.

http://www.codechef.com/viewsolution/5021436