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

What do you mean by a JVM?

0 Answers   GE,


What is a parameter in a function?

0 Answers  


Does every java program need a main?

0 Answers  


Explain the role played by Java Virtual Machine in Java Programming?

1 Answers  


Which method cannot be overridden in java?

0 Answers  


When will we prefer to use set and list in java and why?

0 Answers  


What checkbox method allows you to tell if a checkbox is checked?

0 Answers  


Explain java coding standards for constants?

0 Answers  


Give any two differences between C++ and java.

0 Answers   GrapeCity,


What is the difference between Checked and Unchecked exception? Give some examples

2 Answers   Ness Technologies,


Why we use multi threading instead of multiprocessing?

0 Answers  


how are methods defined?

0 Answers  


Categories