➽ Program:-

import java.util.*;

import java.io.*;

class Main

{

    public static void main(String args[])

    {

        int decimal_number, temp, i=1;

        int binary_number[] = new int[100];

        Scanner sc = new Scanner(System.in);

               

        System.out.print("Enter a Decimal Number: ");

        decimal_number = sc.nextInt();

               

        temp = decimal_number;

               

        while(temp != 0)

        {

            binary_number[i++] = temp % 2;

            temp = temp /2;

        }

               

        System.out.print("Binary Equivalent of "+decimal_number+ " is ");

       

        for(int j=i-1; j>0; j--)

        {

            System.out.print(binary_number[j]);

        }

    }

}

➽ Output:-

Enter a Decimal Number: 185
Binary equivalent of 185 is 10111001