7-127 Sum of the digits (6分)

7-127 Sum of the digits (6分)
 

Given a none-negative number, print out the sum of its digits.

Input Format:

A none-negative integer number.

Output Format:

The sum of its all digits.

Sample Input:

123
 

Sample Output:

6


#include<stdio.h>
int main()
{
 int n;
 int sum=0;
 scanf("%d",&n);
 while(n)
 {
  sum+=n%10;
  n/=10;
  
 }
 printf("%d\n",sum);
 return 0;
}

posted @ 2020-10-17 23:19  罪梦者  阅读(375)  评论(0)    收藏  举报