Skip to main content

Posts

Showing posts with the label to binary

Decimal To Binary

AJ Java Programs Program 9: To Convert Decimal Number into its binary equivalent. For Example: 12 binary equivalent 1100 Syntax: import java.io.*; class dec_to_bin { public static void main(String args[])throws IOException {     int decimal;     BufferedReader br=new BufferedReader(new InputStreamReader(System.in));     System.out.println("Enter a biary Number");     decimal=Integer.parseInt(br.readLine());     int binary=0;     int power=0;         //while(binary.length()>0)     while(decimal>0)     {         int temp = decimal%2;         binary+=temp*Math.pow(10, power++);         decimal=decimal/2;     }     System.out.println(binary); }} Tested Ok Program If You Don't Understand anything or want any program please write your request in Comment Section And Please Like ...