Decimal To Binary In Java ISC & ICSE
Program to convert Decimal to Binary
class DecimaltoBinary{//start of class
public void accept(int n){
String str=" ";
while(n!=0){
int r=n%2;
n=n/2;
str=Integer.toString(r)+str;
}
System.out.println("The binary form is "+str);
}}//end of class
OUTPUT--- WHEN INPUT IS 110
The binary form is 1101110
class DecimaltoBinary{//start of class
public void accept(int n){
String str=" ";
while(n!=0){
int r=n%2;
n=n/2;
str=Integer.toString(r)+str;
}
System.out.println("The binary form is "+str);
}}//end of class
OUTPUT--- WHEN INPUT IS 110
The binary form is 1101110
Comments
Post a Comment