I have written 2 codes. Both are mostly identical but are giving different answers. Can you please help me in identifying the difference and why they are giving different answers.
Code 1:
Code 2:
Thanks in advance