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

write a c program which takes 20 numbers in an array as input from user and rearrange them in two different array defining even or odd

0 Answers  


does anyone know the code to display a triangle using a applet?

1 Answers  


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  


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

14 Answers   Google, Zoho,


Why we r using String args[] in main() even though v r not passing any arguments in command line?

2 Answers  






write a program that will ask the user to enter a number n and display the product of all numbers from 1 to n.

1 Answers  


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

1 Answers   Oracle,


Program to print map of India in java.

2 Answers  


Design a program using one-dimensional array that determines the highest value among the eight input values from a user. Display the difference of each value from the highest to the lowest.

1 Answers   RoboSoft,


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  


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  


write a program that inputs two real numbers then exchanges their values.

7 Answers   Infosys,


Categories