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