0
Decimal to binary.. what is wrong with this program
import java.io.*; class binary { public static void main(String args[])throws IOException { InputStreamReader ob=new InputStreamReader(System.in); BufferedReader ob1=new BufferedReader(ob); int i,n,a; System.out.println("enter the number"); n=Integer.parseInt(ob1.readLine()); i=0; while(n>0) { a=n%2; n=n/2; i++; } for(i=i-1;i>=0;i--) { System.out.print(i); } } }
2 Answers
+ 1
ok thanks