/* Simple Java Program To Find the Sum of digits of number */
class SumDigit
{
public static void main(String args[])
{
int sum, i,a,d;
a = Integer.parseInt(args[0]);
sum = 0;
for(i=1;i< =10;i++)
{
d = a%10;a = a/10;
sum=sum + d;
}
System.out.println("Sum of Digit :"+sum);
}
}
/* Output: 1+2+3+4+5+6+7+8+9+10:55 */
Sunday, September 28, 2008
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment