Arrays- sum or arrays doubt

hey! i wanted to know that in the for loop at line 45, i will approch 0 earlier than j. so, when we further compute sum[j], will the M[i] be zero?

hello @vanya.garg

cb compiler will take 0 . but on other compilers it will give segmentation fault becuase negative index access on array is not allowed.

use if else to hande such cases.

how should i do this? can you please help?

@vanya.garg
check now->

just add only when indexes are >=0

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.