Why can't i take modulous in the end?


#1
int solve(TreeNode* A,int sum)
{
    if(A==NULL)
    {
        return 0;
    }
    sum = (((sum)%1003*10)%1003 + (A->val)%1003)%1003;
    if(A->left==NULL and A->right==NULL)
    {
        return sum;
    }
    int l=solve(A->left,sum);
    int r=solve(A->right,sum);
    return (l+r)%1003;
}
int Solution::sumNumbers(TreeNode* A) {
    return solve(A,0);
}

my code:-
    int solve(TreeNode* A,int sum)
    {
    if(root==NULL)
    {
        return 0;
    }
    sum=sum*10+A->val;
    if(A->left==NULL and A->right==NULL)
    {
        return sum;
    }
    int l=solve(A->left,sum);
    int r=solve(A->right,sum);
    return l+r;
    }
    int Solution::sumNumbers(TreeNode* A) {
    return solve(A,0)%1003;
    }