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 |
Is integer a class?
make a method which any number and any type of argument and print sum of that arguments.....
I am unable to find or learn about print command. I have a graphical program in core java in applet but i want to give print command but i have coding for that so if anyone know about this plz mail me on avdhesh_chauhan007@yahoo.co.in
What are advantages of exception handling in java?
What are different types of control structures?
Why we use methods in java?
What is a qualifier in a sentence?
Can you declare the main method as final?
what is the use of finalize()Method please explain with an example
Explain what is Marker interface?
What is the difference between method overriding and overloading?
Explain the differences between abstraction and encapsulation?