Sum of Digits of a Number

Problem: Program to sum of digits of a given number.

To sum of digits do the following steps:

  1. Get the remainder of a number N by modulo-division with 10 and sum the remainders.
  2. Remove last digit of a number N by dividing it with 10.
  3. Repeat steps 1 and 2 until the value of N becomes 0.
#include<stdio.h>

int main() {
  int num, sum=0;
  scanf("%d",&num);
  while(num!=0){
    sum = sum + num%10;
    num /= 10;
  }
  printf("%d",sum);
  return 0;
}
Sample Input
256
Sample Output
13