0
How to convert name to equivalent number
for example input will be a name like input given is 'Sam' than output should be s+a+m=19+1+13=33
1 Respuesta
+ 2
You just need to cast into int a char to get its ascii code. All letters ( lower and upper case don't be consecutive ) follows each others in the alphabetic order, so if you soustract the ( char code of 'a' - 1 ) to char code of a letter, you get his order number, starting from 1 for 'a'. You can proceed same way for upper case, with ( char code 'A' - 1 ) at calcul base... or convert all your string in upper or lower case...