Sum of subarray

sir my code is successfully compiled but I am getting some garbage value as my sum
please correct my code:

You first need to initialize sum to 0.
Sum=0;
also in for loops everywhere you have written n, check if it should be m.
@Megha2468 if this resolves your doubt mark it as resolved.

sir I did that but sum is coming 1 when it should be

@Megha2468 You did a small mistake in setting range of i and j, it should be i<=bi and j<=bj.


If this resolves your doubt mark it resolved.

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.