Not working for i=0 or j=0 or 2 * 2 matrix

#include

using namespace std;
//sum OF all element approach 2 cumulative sum approach;
int main()
{
int no_row,no_col;
cout<<“enter no of rows and clomns”;
cin>>no_row>>no_col;
int arr[no_row][no_col];
int csum[no_row][no_col];
// taking elements in array
for(int i= 0;i<no_row;i++){
for(int j=0;j<no_col;j++){
cin>>arr[i][j];

    }
}//adding in  row wise
for(int i=0;i<no_row;i++){
    for(int j=0;j<no_col;j++)
    if(j==0){
        csum[i][0]=arr[i][0];
    }
    else{
        csum[i][j]=arr[i][j]+csum[i][j-1];
    }
}// printing row wise cumulative sum
for(int i=0;i<no_row;i++){
    for(int j=0;j<no_col;j++){
        cout<<csum[i][j];
    }cout<<endl;}// cumulative sum column wise
    for(int j=0;j<no_col;j++){
            for(int i=0;i<no_row;i++){
    if(i==0){
        csum[0][j]=csum[0][j];
    }
    else{
        csum[i][j]=csum[i][j]+csum[i-1][j];
    }

    }}//printing after column sum
    for(int i=0;i<no_row;i++){
    for(int j=0;j<no_col;j++){
        cout<<csum[i][j];
    }
    cout<<endl;}
int sum=0;
for(int j=1;j<no_col;j++){
    for(int k = j;k<no_col;k++){
        sum = sum + csum[0][k] - csum[0][j-1] ;
    }
}
 for(int i=1;i<no_row;i++){
    for(int k = i;k<no_row;k++){
        sum = sum + csum[k][0] - csum[i-1][0] ;
    }
}
sum=sum+csum[0][0];

//extracting all possible sub array
// loop to extract top left i-th index
for(int li=1;li<no_row;li++){
    //loop to extract j-th index of top left
    for(int lj=1;lj<no_col;lj++){
        //loop to extract bottom right i index
        for(int bi=li;bi<no_row;bi++){//extracting j-th index
            for(int bj =lj;bj<no_col;bj++){//assigning into sum using cumulative sum
                    sum= sum + csum[bi][bj]-csum[li-1][bj]-csum[bi][lj-1] +csum[li-1][lj-1];


            }
        }
    }
}
cout<<sum;
return 0;

}

Hey @rsaini9416624750
The code is unintelligible this way. Please copy paste it on CB IDE and then send it. Will be happy to help you out then.

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.