Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main(void)
- {
- int i = 0;
- int num = 0;
- int sum = 0;
- printf("Please enter a number\n");
- scanf("%d", &num);
- while(num > 0){
- sum += num%10;
- num /= 10;
- }
- printf("%d", sum);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement