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

Answer Posted / sai

int num=687;
int sum=0;

int i;

System.out.println(num);
for(i=num;(sum>=0)&&(i>0);){
//System.out.println(i);
i=num%10;
System.out.println(i);
sum+=i;
//System.out.println(sum);
num/=10;
//System.out.println(i);
}
System.out.println(sum);

Is This Answer Correct ?    10 Yes 7 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between static and non-static variables in java programming?

517


Why we use multi threading instead of multiprocessing?

572


Can a final variable be null?

541


Can a class be final?

494


Can we have more than one package statement in the source file?

638






What are the advantages of java inner classes?

555


Explain java coding standards for interfaces?

626


What isan abstract class and when do you use it?

837


What is the byte order of byte buffer?

560


What is a native method in java programming?

523


How many types of design patterns are there?

526


What do you mean by scope of variable?

479


What is string and its types?

609


What is hash code collision?

588


What do you mean by constructor?

544