fork(1) download
  1. #include <stdio.h>
  2.  
  3. int main (void){
  4. int num;
  5. printf("welcome to the word of factorial");
  6. printf(" \n plrease enter the number: ");
  7. scanf("%d",&num);
  8. int copy=num;
  9. int sum=0;
  10. while(num>0){
  11. sum +=num % 10;
  12. num/=10;
  13. }printf("the sum of all digits in %d is %d",copy,sum);
  14. return 0;
  15. }
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
welcome to the word of factorial 
 plrease enter the number: the sum of all digits in 32764 is 22