how to solve addition question

CodeChef: Practical coding for everyone how to solve such kind of questions