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

Difference between pass by value and pass by reference?

0 Answers  


What is a reference in C++?

1 Answers  


What do you know about friend class and friend function?

1 Answers  


Describe the syntax of single inheritance in C++?

0 Answers   Fidelity,


Ask to write virtual base class code?

0 Answers   Satyam,






What is #include sstream?

0 Answers  


Explain the concept of copy constructor?

0 Answers  


Declare a class vehicle and make it an abstract data type.

0 Answers  


I need to find a specific string between two strings how do I do it?

1 Answers   Infosys,


Give an example of run-time polymorphism/virtual functions.

0 Answers  


What is a base class?

0 Answers  


What is optimization in c++? when using volatile.optimization is not possible..what does this mean?

1 Answers  


Categories