Sum of Digits Program not giving correct answer for negative number in c
<pre><code>    printf("Sum Digit Program\n");
int n,re, sum = 0;
    printf("Enter an integer n="); scanf("%d", &amp;n);
while(n){
    re = n % 10;
    sum = sum + re;
    n = n / 10;
}
printf("Sum digit = %d", sum);
return 0;
}
</code></pre>

<p>I try this and it works well with positive integer but when I enter a negative integer like: -323 => -8
It's supposed to be -3+2+3 =2 not -3-2-3=-8
I try using abs function but it still doesn't work right  </p>