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 flush c++?

541


What is the limitation of cin while taking input for character array?

1457


Explain abstraction.

619


What is a stack c++?

575


How much is c++ certification?

589






How do you declare A pointer to a function which receives nothing and returns nothing

723


What is the basic of c++?

605


What is a pdb file?

542


How we can differentiate between a pre and post increment operators during overloading?

599


What is setf in c++?

584


Is python better than c++?

588


How would you use the functions sin(), pow(), sqrt()?

742


What is pointer with example?

564


What is function overloading in C++?

735


What are formatting flags in ios class?

608