In circulararray it is getting failed in testcases,whats the error

#include
using namespace std;
int kadane(int a[],int n)
{
int cs=0,ms=0;
for(int i=0;i<n;i++)
{
cs=cs+a[i];
if(cs<0)
{
cs=0;
}
ms=max(ms,cs);
}
return ms;
}
int circularsum(int a[],int n)
{
int c1=kadane(a,n);
int c2=0;
for(int i=0;i<n;i++)
{
c2=c2+a[i];
a[i]=-a[i];
}
c2=c2+ kadane(a,n);
return (c2>c1)?c2:c1;
}
int main()
{
int n,k,t;
cin>>t;
for(k=0;k<t;k++)
{
cin>>n;
int a[1000];
for(int i=0; i<n; i++)
{
cin>>a[i];
}
cout<<circularsum(a,n);
}
return 0;
}

hello @sneha23

please save ur code here->https://ide.codingblocks.com/

and share the generated link with me

data:text/plain;charset=utf-8,%23include%3Ciostream%3E%0Ausing%20namespace%20std%3B%0Aint%20kadane(int%20a%5B%5D%2Cint%20n)%0A%7B%0A%20%20int%20cs%3D0%2Cms%3D0%3B%0Afor(int%20i%3D0%3Bi%3Cn%3Bi%2B%2B)%0A%7B%0A%09cs%3Dcs%2Ba%5Bi%5D%3B%0A%09if(cs%3C0)%0A%09%7B%0A%09%09cs%3D0%3B%0A%09%7D%0A%09ms%3Dmax(ms%2Ccs)%3B%0A%7D%0Areturn%20ms%3B%0A%7D%0A%20int%20circularsum(int%20a%5B%5D%2Cint%20n)%0A%20%7B%0Aint%20c1%3Dkadane(a%2Cn)%3B%0Aint%20c2%3D0%3B%0Afor(int%20i%3D0%3Bi%3Cn%3Bi%2B%2B)%0A%7B%0A%09c2%3Dc2%2Ba%5Bi%5D%3B%0A%09a%5Bi%5D%3D-a%5Bi%5D%3B%0A%7D%0A%09c2%3Dc2%2Bkadane(a%2Cn)%3B%0Areturn%20(c2%3Ec1)%3Fc2%3Ac1%3B%0A%7D%0Aint%20main()%0A%7B%0A%09int%20a%5B1000%5D%3B%0Aint%20n%2Ck%2Ct%3B%0Acin%3E%3Et%3B%0Afor(k%3D0%3Bk%3Ct%3Bk%2B%2B)%0A%7B%0A%20%20%20%20cin%3E%3En%3B%20%0A%20%20%20%20%0A%20%20%20%20for(int%20i%3D0%3B%20i%3Cn%3B%20i%2B%2B)%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20cin%3E%3Ea%5Bi%5D%3B%0A%20%20%20%20%7D%0A%7D%0A%20cout%3C%3Ccircularsum(a%2Cn)%3B%0Areturn%200%3B%0A%7D%0A%0A

sorry i m not able to generate the link frim can u pls tell how to do tht

go to this link -> https://ide.codingblocks.com/
paste ur code
click on file option (present on top )
there u will get save option.
press on save .
a link will be generated in ur search bar.
copy that link and share it with me

print output for each test case in separate line.

ur corrected code link -> https://ide.codingblocks.com/s/339054

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.