Write a program to convert a decimal number to binary form?



Write a program to convert a decimal number to binary form?..

Answer / hamada zahera

String s="";
while(n > 0 ) {

if(n % 2 == 0)
s+="0";
else
s+="1";

n=n/2;

}
s.reverse();

Is This Answer Correct ?    12 Yes 3 No

Post New Answer

More J2SE Code Interview Questions

How can we get the details for printing the employee details at run time using JDBC connectivity? can u provide the coding for that? Its urgent?

2 Answers  


write a program in java to find the moving average of all prime numbers between 2 and 100.

0 Answers  


what is runtime class?

0 Answers   MAQ,


Bubble Sort. java thereafter the user will be asked to inpout the size of the list,sort the list in ascending order and display the sorted list in a horizontal manner???

0 Answers  


1+(2*3)+(4*5*6)+(7*8*9*10)+... specified input value

1 Answers   MAQ,


For printing a message we use System.out.println in normal programs. We use String msg="text....."; Can't we use String msg=" " in normal programs and System.out.println("........") in applets. Please answer this question?

0 Answers  


Program to print map of India in java.

2 Answers  


how to print a message to console without using main() function?(do not use even static blocks also.)

14 Answers   Google, Zoho,


Is there any static classes are in java give some examples

0 Answers  


How to create and run runnable jar file of a Java Project.

4 Answers   HCL, TCS, Tech Mahindra, US Consulate, Wipro,


How Can I Trace A Java Program . Please Give Me Step by Step Process

1 Answers   IBM,


write a java program to create a Frame with three scrolls, change the back ground color of the frame using functions with values of scrolls.

0 Answers  


Categories