We have to find sum of sub array.
Input : -4 1 3 -2 6 2 -8 -9 4
output : 0 -2 4 6 -2 -11 …
I want to ask why the first element in output is 0, I think it should be -4 because when we output sub array, it prints first element and then goes out of loop then it prints -4 1 and so on…
Sub Array(Sum of Sub Array)
Yes…if you are computing the prefix sum…then it must be:
-4, -4+1, -4+1+3, …and so on
that is
-4,-3,0,-2,4,6,-2,-11…
But i want to ask why it shows 0 first in output.
Which code or question are you referring to. Please paste it here so that i can check.
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.