Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

program in java to find the sum of digits of a number

public class sum
{
    public static void main(int a)
    {
        int b =0;
        int c =0;
        for (int i = a ; i>0 ; i=i/10)
        {
            b = i%10;
            c = c+b;
        }
        System.out.println(c);
    }
}
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #program #java #find #sum #digits #number
ADD COMMENT
Topic
Name
1+3 =