c语言编程大一新人提问

img


请问这道题怎么写,急!

#include <stdio.h>
#include <math.h>
int main()
{
    int n,sum=0;
    printf("input data is:");
    scanf("%d",&n);
    n = fabs(n);
    while(n>0)
    {
        sum += n%10;
        n = n/10;
    }
    printf("The sum of the total bit is %d\n",sum);
    return 0;
}