What is wrong in my code

for the problem FLOW004 Problem - CodeChef
why code chef shows my answer is wrong even though i am getting the wright answer in my pc.
below is my code for the problem:
CodeChef: Practical coding for everyone

Your solution gives the wrong answer for single-digit numbers.

1 Like

On Line 28

            total = 2*num[i];

For single digit numbers, the same digit is considered as the starting and the ending digit. Thus you have to add it twice.

1 Like

Thanks for the explanation.