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
Can a program run without main?
What is string in c++ programming?
Is c++ primer good for beginners?
What is the basic structure of c++ program?
What kind of problems can be solved by a namespace?
What are the methods of exporting a function from a dll?
Why do we use vector in c++?
Array base access faster or pointer base access is faster?
What is a v-table?
Explain what is class definition in c++ ?
What is the disadvantage of using a macro?
What are the various situations where a copy constructor is invoked?
Why is swift so fast?
Write some differences between an external iterator and an internal iterator? Describe the advantage of an external iterator.
What will strcmp("Astring", "Astring"); return a) A positive value b) A negative value c) Zero