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);
}
}
Top comments (0)