Write a java code to print the sum of digits of a given number.
Joydeep21:
ok 5pts is ok i tink
Answers
Answered by
3
class DigitSum
{
public static void main(String args[])
{
int i,a=0, sum=0; i=Integer.parseInt(args[0]);
//choose you integer
(i!=0) { a=i%10; i=i/10; sum=sum+a;
}
System.out.println(sum);
}
Hope it helps you out (:
{
public static void main(String args[])
{
int i,a=0, sum=0; i=Integer.parseInt(args[0]);
//choose you integer
(i!=0) { a=i%10; i=i/10; sum=sum+a;
}
System.out.println(sum);
}
Hope it helps you out (:
Similar questions