Maximum Subarray sum problem

i’m facing problem during Run-Time. how to print the output depending upon no. of testcases?
int main() {
int t;
cin>>t;
int n;
int arr[n];
int a[t];
while(t){
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);
}

//for(int i=0; i<t; i++){
    
//}

// for(int i=0; i<t; i++){

cout<<ms<<endl;
 t--;
}
return 0;

}

@samk86676 https://ide.codingblocks.com/s/161240
Please refer this code.This will help you understand.

Hope this helps :slightly_smiling_face: