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

What is the use of endl in c++?

0 Answers  


Should I learn c or c++ first?

0 Answers  


Consider the following code fragment: int main(void) { int m = 4; mystery ( m ); mystery ( m ); printf("%d", m); return 0; } What is the output on the monitor if mystery is defined as follows ? void mystery (int m) { m = m+3; }

2 Answers   CDAC, Wipro,


Does c++ have foreach?

0 Answers  


What is buffering in c++?

0 Answers  






Write a program that takes a 5 digit number and calculates 2 power that number and prints it.

0 Answers   CTS,


What is a float in c++?

0 Answers  


Why do we use classes in c++?

0 Answers  


Is string data type in c++?

0 Answers  


Which operator cannot overload?

0 Answers  


What is an undefined behavior and sequence points

0 Answers  


What is the use of class in c++?

0 Answers  


Categories