Tuesday, February 3, 2026

Java program to convert Decimal to Binary

 import java.util.Scanner;

class D2B

{

public static void main(String[] args)

{

System.out.print("Enter a decimal number :");

Scanner sc = new Scanner(System.in);

int num = sc.nextInt();

String binary = "";

while(num > 0)

{

binary = num%2 + binary;

num = num/2;

}

System.out.print(binary);

}

}

Output:



No comments:

Post a Comment

Henry's law constant for CO 2 ​ in water is 1.67×10 ∘ Pa at 298 K . Calculate the quantity of CO 2 ​ in 500 mL , of soda water when packed under 2.5 atm CO 2 ​ pressure at 298 K .

  Explanation To calculate the amount of CO 2 ​ dissolved, we use Henry's Law: P = k H ​ × x _ C O 2 ​ where:\ P = partial pressure of...