Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. #include <stdlib.h>
  4.  
  5. int main() {
  6. long int i, n, sum = 0;
  7. printf("Enter number:\n");
  8. scanf("%ld", & n);
  9. for (i = 1; i <= n; i++) {
  10. sum = sum + n % 10;
  11. n = n / 10;
  12. }
  13. printf("Sum of digits is %ld", sum);
  14. return 0;
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement