Calculate the sum of digits of a number with C

#include <stdio.h>

int main()
{
int num, sum = 0;

printf("Enter the  digit: ");
scanf("%d", &num);

while (num != 0)
{
 sum += num % 10;
num = num / 10;
}
printf("Sum of digits = %d", sum);
return 0;
}

Output:-


Enter the digit : 4578
Sum of digits = 24