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); } } }

3rd Jan 2018, 7:54 AM
Shabnam Perween
Shabnam Perween - avatar
2 Answers
+ 1
ok thanks
3rd Jan 2018, 8:48 AM
Shabnam Perween
Shabnam Perween - avatar