Maximum Subarray Sum

the code is having a run time error, why?
#include
#include

using namespace std;
int main() {
int t;
cin>>t;
int n;
int arr[n];

while(t>0){
cin>>n;
int cs=0,ms=0;

for(int i=0; i<n ;i++){
cin>>arr[i];
}
for(int i=0; i<n ; i++){
cs=cs+arr[i];
if(cs<0){
cs=0;
}
ms= max(cs, ms);
}
cout<<ms<<endl;
t–;
}
return 0;
}

there is just one sign wrongly assigned i.e.
t–(t minus minus)
improve this & your code is good to go

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.

I have wrote t–; here, it is a copy paste mistake. My code is able to show output of one testcase at a time, and again it will ask to insert the 2nd array elements. I think i need to write a code which is capable of showing all outputs together once i entered all testcases input elements. Is this is so?

yes, feel free to share your code again if it gives error!