Doubt in string part of the code

i am getting a bit confused in the string part . i calculated the length of the string as 5 , then if we want to convert the last character to number why are we doing a[n-1]and not a[n].

because last digit at 4th(n-1) index not 5th(n)

if n=12345
then 5 is at 4th index
in array index start from 0