’ cin >> a[0] ;
cumsum[0] = a[0] ; ’
Why we did this???
Because we did not enter the value for ’ a[0] '…
we just entered the value for ‘n’ and 'a [ i ] '.
Doubt doubt doubt
hello @parth_tyagi
look at line 23, here we are accessing cumSum[i-1].
if we will start from i=0 then i-1 will be -1 and we cannot access negative index.
so to avoid it , we have handled i==0 case seprately by doing this->
and for remaining i = [1…n-1] we are using loop
i have not got the answer yet.
…
what u didnt get?
what i meant was that we use ’ cin ’ to extract value… but here we did not enter any value for ’ a[0] ’ like we did for array.
And your answer not visible yesterday…that is why i wrote that ‘i have not got the answer yet.’
And i get that we want [i-1] to start calculating comulative sum… my question is that we wrote cin>> a[0]; …but did not enter any value for 0th index.
…
at the time of giving input, we do give value for 0th index as well.
once rewatch the video