Decimal to Binary conversion

Java Program to Convert a Decimal Number to Binary.

import java.util.Scanner;
class DecimalToBinary
    public static void main(String args[])
        Scanner in = new Scanner(;
        System.out.println("Enter a decimal number");
        int num = in.nextInt();
        String b = "";
        int t = num;
            int r = t%2;
            t = t/2;
            b = r + b;
        System.out.println("Binary Equivalent of " +num+ " is " +b);

Video explanation

1 thought on “Decimal to Binary conversion”

  1. Sir or Bhaiya I’m dhairya of icse class X
    Please make a video on string handling programs like pyramid pattern

Leave a Comment

Your email address will not be published. Required fields are marked *