Help me in solving FLOW004 problem

My issue

My code

#include<stdio.h>
int main()
{
    int num,temp,fn,ln,sum,no,i;
    scanf("%d",&no);
    for(i=1;i<=no;i++)
    {
        scanf("%d",&num);
        temp=num;
        ln=num%10;
        while(num>10)
        {
            num=num/10;
        }
        fn=num;
        sum=fn+ln;
        printf("\n %d ",sum);
    }
    return 0;
}


Problem Link: CodeChef: Practical coding for everyone
The above program is not showing any error but during any submission it is showing wrong submission.

@janani68

You program might pass the sample test cases but it checked for a variety of hidden test cases during submission for which the program might not be correct.

One edge case that I can see is the number having first two digits as 10, in which case, your while loop will not execute as it does not satisfies the condition of being greater than 10. So, now for a number like 1034, your code would return answer as 14 whereas, the correct answer should be 5.

Try changing the while loop condition to being greater than 9, (num>9).

Here is a code for reference.

#include <stdio.h>

int main()
{
    int ld,n,t,r;
    
    scanf("%d",&t);
    while(t--){
        scanf("%d",&n);
        ld = n%10;
        while(n>0) {r=n%10; n/=10;}
        printf("%d\n",r+ld);
    }
    return 0;
}