Always returning a negative sum

hi @Varun_a19

you have to just do some modification

  int sum=0;
  sum=a[bi][bj];
  if(li>0&&bj>0)sum+=a[li-1][lj-1];
  else if(li>0)sum+=a[li-1][bj];
  else if(lj>0)sum+=a[bi][lj-1]; 

in your case

sum=a[bi][bj]-a[li-1][bj]-a[bi][lj-1]+a[li-1][lj-1];

if li lj are 0 then it will throw error or garbage

i hope you understand

if your doubt is resolved please mark it as resolved form your doubt section inside your course