fork download
  1. #include <stdio.h>
  2. int main(){
  3. int N,s;
  4. scanf("%d",&N);
  5. s=0;
  6. while(N>0){
  7. s+=N%10;
  8. N/=10;
  9. }
  10. printf("%d\n", s);
  11. return 0;
  12. }
  13.  
Success #stdin #stdout 0s 544KB
stdin
145
stdout
10