DECIMAL TO BINARY

This is the programe converting Decimal Number to Binary Number..

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
java.io.*;
class DecimalToBinary
{
        public static void main(String args[]) throws IOException
        {
            int a[] = {0, 1};
            int number;
            int r;
            BufferedReader Input = new BufferedReader( new InputStreamReader(System.in));
            System.out.print("Enter Decimal Number: ");
            number = Integer.parseInt( Input.readLine());
            System.out.println("binary numbers are:");
            do{
                    r=number%2;
                    if(r!=0){
                    System.out.println(a[1]);
              }
            else
            {
                System.out.println(a[0]);
            }
                number=number / 2;}
                while(number>0);
        }
}

Output :Decimal Number to Binary

binary