convertToInt method

why in the above method in ans+=s[i]-‘0’ is done?
i didn’t understand the logic behind subtracting a zero and then multiplying.

hello @Suruchi

to convert char to integer we subtract ‘0’ from that char.

for example is char is ‘8’ then to get integer 8 we subtract ‘0’ from ‘8’

i,e ‘8’-‘0’=8