write the programme that convert a interger to biniry number

Answer Posted / bunny_1996

import java.util.Scanner;
public class HelloWorld{

public static void main(String []args){
Scanner scr=new Scanner(System.in);
int no,i=0,a=0;
int [] x=new int[20];
System.out.println("Enter the decimal number");
no=scr.nextInt();
while(no!=0)
{
a=no%2;
no=no/2;
x[i]=a;
i++;
}
int len=i;
for(i=len-1;i>=0;i--)
{
System.out.print(""+x[i]);
}
}
}

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the cout in c++?

552


Why is null pointer used?

680


Write a program to find the reverse Fibonacci series starting from N.

608


Write about a nested class and mention its use?

630


Is java the same as c++?

547






How the delete operator differs from the delete[]operator?

642


What is abstract class in c++?

587


What is a hash function c++?

554


What does catch(…) mean?

610


Why iomanip is used in c++?

635


What are namespaces in c++?

595


What is the difference between #import and #include in c++?

596


What is const in c++?

598


What are pointer-to-members? Explain.

630


What is the use of :: operator in c++?

597