if num=687;
U have to get
num=6+8+7;
Answers were Sorted based on User's Feedback
Answer / 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 |
Answer / 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 |
Answer / asit purohit
int num=5672;
int sum=0;
while(num%10!=0)
{
sum=sum+num%10;
num=num/10;
}
System.out.println("sum="+sum);
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / 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 |
Explain about the select method with an example?
how to one war file class to another war file class?
What happens when I use / and % with a negative numerator?
What are the kinds of polymorphism?
what is the difference b/w static and final methods?
What are the legal parameters?
What do you mean by object?
How to obtain a performance profile of java program
what is actual real time using of oops concepts in projects(Interface,polymorphism.abstraction.........)
What's the purpose of static methods and static variables?
What are the main features of java?
How do you check if an arraylist is not empty?