Computer Science, asked by aakash11k, 1 year ago

can anyone teach me about converting decimal numbers in to binary numbers

Answers

Answered by sutharshan
1
I can teach you

.. for example take 45 *10

45÷2

aakash11k: then it would be 00110100 00110101
Answered by lichidash48pbhfh2
0
in java i can help
here it is:
import java.util.Scanner;
public class Convert
{
public static void main(String[] args)
{
int n, count = 0, a; String x = "";
       Scanner s = new Scanner(System.in);

System.out.print("Enter any decimal number:");
        n = s.nextInt();
while(n > 0)

{
            a = n % 2;
if(a == 1)
{
                count++;
}
            x = x + "" + a;
            n = n / 2;
}
System.out.println("Binary number:"+x);
System.out.println("No. of 1s:"+count);
}
}
Similar questions