write the programme that convert a interger to biniry number



write the programme that convert a interger to biniry number ..

Answer / 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

More C++ General Interview Questions

Why do we use using namespace std in c++?

0 Answers  


What is jump statement in C++?

0 Answers   Ericsson,


Carry out conversion of one object of user-defined type to another?

0 Answers  


What is difference between c++ and c ++ 14?

0 Answers  


What return value must conversion operators have in their declaration?

0 Answers  






What is the use of data hiding?

0 Answers  


differance between copy & clon

1 Answers   Microsoft,


What is meant by entry controlled loop? What all C++ loops are exit controlled?

0 Answers   TCS,


Give the difference between the type casting and automatic type conversion. Also tell a suitable C++ code to illustrate both.

0 Answers   TCS,


Is c++ a dying language?

0 Answers  


How can you quickly find the number of elements stored in a dynamic array?

0 Answers  


What is #include math h in c++?

0 Answers  


Categories