Raj Kumar Bindal wrote:Please suggest the solution which can be considered generic for all programming languages.
There isn't a solution which is language-independent. If you're working in a procedural C-like language, such as Java for example, then you would go through the string one character and a time, converting the characters to numbers and adding them up. Whereas in a functional language like Lisp, you would more likely write a recursive function which added the number corresponding to the first character of the string to the value of that same function applied to the rest of the string.