(-2+5)%5=((-2%5)+(5%5))%5=((-2)+0)%5=-2%5;
so why we add 5 nothing is changed
Please clear ths doubt
completely agree with your point
the only reason we add n
is because we are trying to access that index
and we can in no way access -2
so (-2+n)%n as u said will have made no difference on the original expression
but it makes the index +ve and hence pre[sum]++ can be done
else we will get an error
but how? after evaluation of sum we will get negative value only so afterall we are doing pre[-2]
please explain
i did not get your point please give example of what u are trying to tell