decimal to binary
unknown
java
10 months ago
321 B
6
Indexable
public static void decToBin(int n){
int binNum=0;
int pow=0;
while(n>0){
int rem=n%2;
binNum=binNum+(rem*(int)Math.pow(10,pow));
pow++;
n=n/2;
}
System.out.println(binNum);
}
public static void main(String args[]){
decToBin(15);
}
Editor is loading...
Leave a Comment