Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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

Answers were Sorted based on User's Feedback



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

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

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

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

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

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

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

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

Post New Answer

More Core Java Interview Questions

Is integer a class?

0 Answers  


make a method which any number and any type of argument and print sum of that arguments.....

0 Answers  


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

0 Answers  


What are advantages of exception handling in java?

0 Answers  


What are different types of control structures?

0 Answers  


Why we use methods in java?

0 Answers  


What is a qualifier in a sentence?

0 Answers  


Can you declare the main method as final?

0 Answers  


what is the use of finalize()Method please explain with an example

3 Answers  


Explain what is Marker interface?

0 Answers   BirlaSoft,


What is the difference between method overriding and overloading?

0 Answers  


Explain the differences between abstraction and encapsulation?

0 Answers  


Categories