Not able to write correct code


plz help to correct the above code

Hello @rohitkandpal683,

Add some conditional checks to your code to avoid such cases:

The junk values are getting added and subtracted from the sum for the cases:

  • When li=0
  • when lj=0

You have to check for these cases before computing the sum.

I have corrected your code:

Refer to the comments for better understanding of the changes:

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