Max circular sum

can u please check what i am still doing wrong in this programme
#include
using namespace std;
int main()
{
int t;
//cout << “Enter number of testcases:”;
cin >> t;
for (int i = 0; i < t; i++)
{
int n;
//cout << “Enter number of elements:”;
cin >> n;
int *a = new int[n];
//cout << “Enter elements:” << endl;
for (int j = 0; j < n; j++)
{
cin >> a[j];
}
int cumsum = 0,csum = 0, msum = 0;
for (int j = 0; j < n; j++)
{
csum = csum + a[j];
cumsum = cumsum + a[j];
if (csum < 0)
{
csum = 0;
}
if (csum>msum)
{
msum = csum;
}
}
for (int j = 0; j < n; j++)
{
a[j] = -a[j];
}
int csum1 = 0, msum1 = 0;
for (int j = 0; j < n; j++)
{
csum1 = csum1 + a[j];
if (csum1 < 0)
{
csum1 = 0;
}
if (csum1>msum1)
{
msum1 = csum1;
}
}
msum1 += cumsum;
if (msum1 > msum)
{
cout << msum1;
}
else
{
cout << msum;
}
delete []a;
}
cin.get();
system(“pause”);
return 0;

}

Hello @radhika1995

Print the answer for each testcase in a different line using ‘\n’ OR endl;
Also you should break your program into modules.
I broke your program into modules and modified it. Here it is

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.