What is the mistake

int main()
{
int n,arr[100][100],sum=0;
cin>>n;
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
cin>>arr[i][j];
}
}
for(int ti=0;ti<n-1;ti++)
{
for(int tj=0;tj<n-1;tj++)
{

for(int bi=ti+1;bi<n-1;bi++)
{
    for(int bj=tj+1;bj<n-1;bj++)
    {
        for(int i1=ti;i1<bi;i1++)
        {
            for(int j1=tj;j1<bj;j1++)
            {
                sum=sum+arr[i1][j1];
            }
        }
    }
}
}
}
cout<<sum;
return 0;

}

Hello @Madhukar,

There are many logical errors in the six nested for loops you have used.
I have modified all:


You can compare your code with this to understand the mistake.

Hope, this would help.
Give a like if you are satisfied.