Write a Program to find sum of the number

class sum
{
 public static void main(String...s)
 {
  int n,i,sum=0;
  System.out.println("Enter the number:");
  n=Integer.parseInt(s[0]);        
  while(n!=0)
  {
   i=n%10;
   sum+=i;
   n/=10;
  }        
  System.out.println(sum);
 }
}

Output

Enter the number: 1 6 9

16
 

Explanation

Here you will get java program to find sum of digits of a number. For example if given digit is 1 6 9 then its sum will be 16.