# Code is not displaying the desired Output.Plz provide the correct code for finding the sum of all sub matrices for a given matrix in 0(n^6)

#include
using namespace std;

void find_Submatrices(int A[][5],int n)
{
int li,lj,bi,bj,i,j;
int sum;
for(li=0;li<n;li++)
{
for(lj=0;lj<n;lj++)
{
for(bi=li+1;bi<n;bi++)
{
for(bj=lj+1;bj<n;bj++)
{
for(i=li;i<bi+1;i++)
{
sum=0;
for(j=lj;j<bj+1;j++)
{

``````                        sum=sum + A[i][j];
cout<<sum<<endl;
}
}
}
}
}
}
``````

}

int main()
{
int A[5][5];
int n;
cin>>n;
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
cin>>A[i][j];
}
}
find_Submatrices(A,n);

}

hi @Mukul-Shane-1247687648773500
refer this -->

``````#include<iostream>
using namespace std;
int main(){
int n,arr[10][10];
cin>>n;

int i,j,li,lj,bi,bj;

for(i=0;i<n;i++){
for(j=0;j<n;j++){
cin>>arr[i][j];
}
}

int sum=0;
for(li=0;li<n;li++){
for(lj=0;lj<n;lj++){
for(bi=li;bi<n;bi++){
for(bj=lj;bj<n;bj++){
for(i=li;i<=bi;i++){
for(j=lj;j<=bj;j++){
sum+=arr[i][j];
}
}
}
}
}
}
cout<<"sum is "<<sum;
cout<<endl;

}
``````

hi @Mukul-Shane-1247687648773500
i hope its clear now??