Code is giving wrong answer

why is my code not working when I try with a[i] ,and it’s giving correct answer when I store a[i] in variable e. code link: https://ide.codingblocks.com/s/469361

hello @s.kumar

a[i] will get changed during iteration, so store its value in some variable and then use that variable.

but why will a[i] get changed, as I’m doing any modification in a[i] during iteration

@aman212yadav
yeah, understood.
thanks

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.