Java Program for converting Decimal To binary.
package decimal.to.binary;
import static java.time.Clock.system;
import java.util.Scanner;
public class DecimalToBinary {
public static void main(String[] args) {
Scanner s=new Scanner(System.in);
System.out.println("enter the decimal no");
int decimal=s.nextInt();
int i=0;
int r[]=new int[decimal];
while( decimal >0)
{
r[i++]=decimal%2;
decimal=decimal/2;
}
for(int j=i-1;j>0;j--)
{
System.out.println(r[j]);
}
}
}
No comments:
Post a Comment