I want to write a program that displays dijits of numbers and adds dijits | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

I want to write a program that displays dijits of numbers and adds dijits

765 to display dijits and add them

7th Jan 2019, 5:58 PM
Awel Kasim
Awel Kasim - avatar
1 Answer
+ 8
● run a loop till n doesn't become 0 ● use r=n%10 to get last digit of a number n as r. //print it. ● use sum = sum + r //for adding last digit everytime ● use n=n/10 for for removing units digit of number n. //can do through recursion also, give it a try, if get struct U can insert the code & ask your doubt 👍
7th Jan 2019, 6:15 PM
Gaurav Agrawal
Gaurav Agrawal - avatar