for(int j=0;j<n;j++){
//maximum=csum[j];
for(int k=j;k<n;k++){
maximum=max(maximum,csum[k]-csum[j-1]);
cout<<csum[k]<<" "<<csum[j-1]<<endl;
in this for j=0 iteraation, why it is not giving error since csum[-1] is not defined.
for(int j=0;j<n;j++){
//maximum=csum[j];
for(int k=j;k<n;k++){
maximum=max(maximum,csum[k]-csum[j-1]);
cout<<csum[k]<<" "<<csum[j-1]<<endl;
in this for j=0 iteraation, why it is not giving error since csum[-1] is not defined.
@Ignitor Yes you should prevent negative indexes in the array as it may have some unexpected results depending on the compiler. But here it is not causing any error and taking cumSum[-1] as 0. It basically depends on the compiler.