DEV Community

Cover image for Java program to find Sum of Digits
realNameHidden
realNameHidden

Posted on

1 1 1 1 1

Java program to find Sum of Digits

For Explanation watch the video

code ::

import java.util.*;
import java.lang.*;
class Demo{
    public static void main(String[] args){
        int n = 555;
        int sum = 0;
        while(n>0){
            int r = n%10;
            sum = sum + r;
            n = n/10;
        }
        System.out.println(sum);
    }
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more