In the function convert to int

in the statement : ans += ((s[i]-“0”)*p)
why did we do (-“0”)??

Hello @Amishi we have done this because characters in their ascii value when ascii value of 0 I.e 48 is subtracted it gives us the actual string to integer.

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.