Program to find the addtion of digits of a number | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 2

Program to find the addtion of digits of a number

26th Jul 2017, 4:07 PM
Mohammed Suhail
Mohammed Suhail - avatar
5 Answers
+ 3
What is "addition of digits", and your question?
26th Jul 2017, 4:52 PM
Rrestoring faith
Rrestoring faith - avatar
+ 1
If you take the number % 10, you will get the first digit of the number. Then, you can add thay digit to the sum. Once that's done you can move to the next digit by dividing the number by 10. loop/repeat what I said above until the number is less than 1 (or equal to 0), and you've added all the digits!
27th Jul 2017, 3:13 PM
Rrestoring faith
Rrestoring faith - avatar
0
for example.. consider this number 648 i need the output to be 6+4+8=18
27th Jul 2017, 2:56 PM
Mohammed Suhail
Mohammed Suhail - avatar
0
can write a proram fr that
27th Jul 2017, 3:15 PM
Mohammed Suhail
Mohammed Suhail - avatar
0
Hello. My shot to get this result. It is in Python but that's easy to implement in any language. https://code.sololearn.com/c5b5lR2oz98r/?ref=app
16th Aug 2017, 3:40 PM
Carlos J Sousa
Carlos J Sousa - avatar