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>
#include <stdlib.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char *argv[]) {
int n=0,sum=0;
scanf("%d",&n);
while(n!=0)
{
sum+=n%10;
n/=10;
}
printf("%d",sum);
return 0;
}