200k views
4 votes
Write a algorithm to calculate the sum of digits in a given three digit number



User Mazatwork
by
4.0k points

1 Answer

2 votes


{\huge{\pink{↬}}} \:  \: {\huge{\underline{\boxed{\bf{\pink{Answer}}}}}}

Sum of digits algorithm

Step 1: Get number by user.

Step 2: Get the modulus/remainder of the number.

Step 3: sum the remainder of the number.

Step 4: Divide the number by 10.

Step 5: Repeat the step 2 while number is greater than 0.

User Aoetalks
by
4.1k points