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

Answer Posted / sadikhasan palsaniya

int no=687;
int sum=0;
int temp;

while(no>0)
{
temp = no % 10;
sum += temp;
no = no/10;
}
System.out.println(sum);

Is This Answer Correct ?    9 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to sort elements in a parallel array in java?

508


What is a pattern what is an anti pattern?

512


What are desktop procedures?

563


Can an anonymous class be declared as implementing an interface and extending a class in java programming?

651


Why is java architectural neutral?

618






How to restrict a member of a class from inheriting by its sub classes?

805


What is java algorithm?

525


Describe the term diamond problem.

576


What is method reference in java?

566


What is mean by encoding?

628


How to sort list of list in java?

664


What is final access modifier in java?

595


What is the difference between synchronized and synchronized block?

507


What is a cup of java?

562


What is the difference between the final method and abstract method?

542