What is the mistake in my code

what is the mistake in my code

hey @shiva57reddy, please share the code saved in coding blocks ide.

#include

using namespace std;

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

while(–t)
{

int a[100],n;
int c_sum,max1;

c_sum = max1 = 0;

cin >>n;

for(int i = 0;i < n;i++)
cin>>a[i];

for(int i = 0;i < n;i++)

{ c_sum = c_sum + a[i];
if(c_sum < 0)
c_sum = 0;

  max1 = max(max1,c_sum);

}
cout <<max1;
}
}

hey @shiva57reddy, do the folleing changes

  1. just do post decrement of varible t instead of predecrement.
  2. change datatype to long int or long long int.
  3. increase the size of array to 100000
  4. put endl when you are printing the answer.

Updated code https://ide.codingblocks.com/s/106337