Maximum subarray sum output

#include
#include
using namespace std;

int maxSubArraySum(long int a[],long int size)
{
long int max_so_far = INT_MIN, max_ending_here = 0;

for (int i = 0; i < size; i++)
{
	max_ending_here = max_ending_here + a[i];
	if (max_so_far < max_ending_here)
		max_so_far = max_ending_here;

	if (max_ending_here < 0)
		max_ending_here = 0;
}
return max_so_far;

}

int main()
{
long int a[100000],n,t,max_sum[100000];
cin>>t;
cin>>n;
for(int j=0;j<t;j++)
{
for(int i=0;i<n;i++)
{
cin>>a[i];
}
max_sum[j] = maxSubArraySum(a, n);
}
for(int i=0;i<t;i++)
{
cout<<max_sum[i]<<endl;
}
return 0;
}
I AM HAVING A BLANK SCREEN AS OUTPUT WHEN I SUBMIT THIS CODE BUT I GET RUN ERROR WHEN I TAKE THE SIZE OF ARRAY AS 10. WHAT IS WRONG IN THIS CODE??.

Shubham, You are required to use kadane’s algo in the code for finding the maximum subarray sum, and since constraints are large, its better to use long long int values…

OK I WILL TRY KADANE;S ALGO. THANK U:smiley: