decimal to binary
Anonymous
java
02/24/2025 4:51 PM
428 B
17
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