Circular array maximum sum

#include
using namespace std;
int kadane(int a[], int n)
{
int currentsum=0;
int maxsum=0;
for(int i=0;i<n;i++)
{
currentsum+=a[i];
if(currentsum<0)
{
currentsum=0;
}
maxsum=max(currentsum,maxsum);
}
return maxsum;
}

int circular(int a[],int n)
{
int c1=kadane(a,n);
int c2=0;
for(int i=0;i<n;i++)
{
c2+=a[i];
a[i]=-a[i];
}
c2=c2+kadane(a,n);
return (c2>c1)?c2:c1;
}

int main()
{
int t;
cin>>t;
for(int i=0;i<t;i++){

int a[1000];
int n;
cin>>n;
for(int i=0;i<n;i++)
{
	cin>>a[i];
}
cout<<circular(a,n);

}
return 0;
}

hello @vrcoolbuddy08
pls share ur code using cb ide.

i am sharing this code through my cb id i.e [email protected]

see follow these steps->
a) go to -> https://ide.codingblocks.com/
b) paste ur code in the editor, then go to file option (present on top navbar)
c) there u will get save option click on it , a link will be generated in ur search bar.
d) copy that link and share it with me

@vrcoolbuddy08
print output for each test case in seprate line

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.