pastebin

Paste Search Dynamic
Recent pastes
The sum of the digits
  1. #include<stdio.h>
  2. main ()
  3. {
  4. int number, a, b, total;
  5. printf ("Enter the number whose sum of digits is to be calculated: ");
  6. scanf ("%d", &number);
  7. a = number%10;
  8. total = a;
  9. b = (number/10) % 10;
  10. total = total + b;
  11. b = (number/100) % 10;
  12. total = total + b;
  13. b = (number/1000) %10;
  14. total = total + b;
  15. b = (number/10000) %10;
  16. total = total + b;
  17. printf ("The sum of the digits of the entered number is: %d", total);
  18. }
  19.  
Parsed in 0.003 seconds