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
Should the member functions which are made public in the base class be hidden?
Can manipulators fall in love?
What are the advantages of using a pointer? Define the operators that can be used with a pointer.
How can I disable the "echo" feature?
Where must the declaration of a friend function appear?
What is null pointer and void pointer and what is their use?
What is difference between class and structure in c++?
What is an overflow error?
How should a contructor handle a failure?
What does the linker do?
How will you call C functions from C ++ and vice-versa?
What is a loop? What are different types of loops in c++?
What are abstract data types in c++?
Are c and c++ similar?
what is COPY CONSTRUCTOR and what is it used for?