java program to print sum of digits of a number using for loop.
Answers
Answered by
0
Answer:
) Here we are using the for loop to calculate the sum of digits of a number. 2) Read the entered long value using scanner class object sc.nextLong(). 3) The for loop iterates up to n!=0, here sum=0, and n=n/10,add the remainder of n/10 to the sum until n!=0 is false.
Explanation:
Similar questions