Program to find sum of Digits
Oct 5, 2013
Make sure to subscribe to our newsletter and be the first to know the news.
Oct 5, 2013
Make sure to subscribe to our newsletter and be the first to know the news.
public class SumOfDigits
{
public static void main(String[] args)
{
int i = 234;
int sum = 0;
int remainder;
System.out.println("Number Entered: " + i);
while ( i > 0 )
{
remainder= i%10;
sum=sum+remainder;
i=i/10;
}
System.out.println("digits after calculation: " +sum);
}
}