Problem in declaration of p and ans variable


This is the link of code I have written. I want to ask that what is the problem If I define ans and p variable inside the loop.

hello @nikhil.1104

it will keep getting reinitilasie on every iteration , so u will not be able to get expected result

Okay, I got it.
Thankyou!

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.