What is the issue with my implementation?

#include<iostream>
using namespace std;
int main(){
     int a,b;
     cin>>a>>b;
     int c[100][100];
     for (int i = 0; i < a; i++)
     {
         for (int j = 0; j < b; j++)
         {
            cin>>c[i][j];
         }
     }
     int sum=0;
     for (int i = 0; i < a; i++)
     {
         for (int j = 0; j < a; j++)
         {
             for (int k = i+1; k < a; k++)
             {
                 for (int l = j+1; l < a; l++)
                 {
                     for (int q = i; q <= k; q++)
                     {
                        for (int z = j; z <= l; z++)
                        {
                            sum+=c[q][z];
                        }
                        
                     }
                     
                 }
                 
             }
             
         }
         
     }
     
     cout<<sum;
    return 0;
}

hello @sagar_aggarwal
image

here initialise k with i and l with j.
becase 1 X 1 is also a valid submatrix

Thanks aman,concept in the tutorial was bit confusing

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.