WAP to find the sum of digits of the entered number.

WAP to find the sum of digits of the entered number. 

#include<stdio.h>
int main(){
  int num,sum=0,r;
  printf("Enter a number: ");
  scanf("%d",&num);
  while(num){
      r=num%10;
      num=num/10;
      sum=sum+r;
  }
  printf("Sum of digits of number:  %d",sum);
  return 0;
}
Output 
Enter a number: 123
Sum of digits of number:  6
Paper Code: 
NCS 151 NCS 252
Programmes: 
B.Tech