Java program to find Sum of Digits

Total
0
Shares

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

Total
0
Shares
Valentsea

Smooth Sailing with Docker: A Beginner’s Guide to Containerization

Welcome to Docker world where containers bring magic to the world of software development and deployment! Why did…

You May Also Like