if num=687;
U have to get
num=6+8+7;

Answer Posted / asit

public class addDigit {
public static void main(String args[])
{
int num=56782;
int sum=0;
while(num!=0)
{
sum=sum+num%10;
num=num/10;
}
System.out.print(sum);
}

}

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is singleton class example?

585


What does singleton mean in java?

508


what state does a thread enter when it terminates its processing? : Java thread

593


How many bytes is a string in java?

527


Explain the overview of UDP messaging.

731






What is a function in java?

563


What are the different http methods?

527


When a thread is executing synchronized methods , then is it possible to execute other synchronized methods simultaneously by other threads?

564


Can extern variables be initialized?

509


What is default size of arraylist in java?

553


How do you avoid global variables?

535


What is the benefit of inner classes in java?

601


What are 3 boolean operators?

527


Do I need java on my computer?

524


What are the features of junit?

598