1. Start.
2. Initialize, sum=0.
3. Read number.
4. If number < 0 , Get absolute value of number into the variable number.
5. While number > 0
digit = number % 10;
sum = sum + digit;
number = number / 10;
6. Print sum of digits.
7. End.
2. Initialize, sum=0.
3. Read number.
4. If number < 0 , Get absolute value of number into the variable number.
5. While number > 0
digit = number % 10;
sum = sum + digit;
number = number / 10;
6. Print sum of digits.
7. End.
No comments:
Post a Comment