swapnil decNum=int(input()) rem=0 res=[] originalNum=decNum while decNum>0: rem=decNum%2 decNum=decNum//2 res.append(rem) print(”.join(str(i) for i in res[len(res)-1::-1])) Log in to Reply
The Bong import java.util.Stack; public class DecimelToBinary { public static void main(String[] args) { System.out.println(decToBinary(50)); } static String decToBinary(int num) { Stack stack = new Stack(); String resString = “”; int temp = num; while (temp >= 1) { String remainder = String.valueOf(temp % 2); stack.push(remainder); temp /= 2; } while (!stack.isEmpty()) { resString += stack.peek(); stack.pop(); } return resString; } } Log in to Reply
n=int(input())
print(str(bin(n))[2:])
#Python
a=int(input())
c=str(bin(a))
print(c[2:])
decNum=int(input())
rem=0
res=[]
originalNum=decNum
while decNum>0:
rem=decNum%2
decNum=decNum//2
res.append(rem)
print(”.join(str(i) for i in res[len(res)-1::-1]))
import java.util.Stack;
public class DecimelToBinary {
public static void main(String[] args) {
System.out.println(decToBinary(50));
}
static String decToBinary(int num) {
Stack stack = new Stack();
String resString = “”;
int temp = num;
while (temp >= 1) {
String remainder = String.valueOf(temp % 2);
stack.push(remainder);
temp /= 2;
}
while (!stack.isEmpty()) {
resString += stack.peek();
stack.pop();
}
return resString;
}
}