separate digits and alphabets
for ( int i = 0 ; i < n ; i ++ ) { if ( str [ i ] >= '0' && str [ i ] <= '9' ) { digitSum += ( int ) ( str [ i ] - '0' ) ; } else { alphabetSum += str [ i ] - ' a ' + 1 ; alphabetSum %= 26 ; } }