This content originally appeared on DEV Community and was authored by NJ
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);
}
}
This content originally appeared on DEV Community and was authored by NJ
Print
Share
Comment
Cite
Upload
Translate
Updates
There are no updates yet.
Click the Upload button above to add an update.
APA
MLA
NJ | Sciencx (2023-05-14T09:58:24+00:00) Java program to find Sum of Digits. Retrieved from https://www.scien.cx/2023/05/14/java-program-to-find-sum-of-digits/
" » Java program to find Sum of Digits." NJ | Sciencx - Sunday May 14, 2023, https://www.scien.cx/2023/05/14/java-program-to-find-sum-of-digits/
HARVARDNJ | Sciencx Sunday May 14, 2023 » Java program to find Sum of Digits., viewed ,<https://www.scien.cx/2023/05/14/java-program-to-find-sum-of-digits/>
VANCOUVERNJ | Sciencx - » Java program to find Sum of Digits. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2023/05/14/java-program-to-find-sum-of-digits/
CHICAGO" » Java program to find Sum of Digits." NJ | Sciencx - Accessed . https://www.scien.cx/2023/05/14/java-program-to-find-sum-of-digits/
IEEE" » Java program to find Sum of Digits." NJ | Sciencx [Online]. Available: https://www.scien.cx/2023/05/14/java-program-to-find-sum-of-digits/. [Accessed: ]
rf:citation » Java program to find Sum of Digits | NJ | Sciencx | https://www.scien.cx/2023/05/14/java-program-to-find-sum-of-digits/ |
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.