Code to convert decimal to binary numbers?

#without using built-in function
decimal=int(input("enter the number: "))
binary = 0
ctr = 0
temp=decimal

while temp >0:
binary=(temp%2)*(10**ctr)+binary
ctr+=1
temp=temp//2
print(binary)

2 Likes

@amoghrane56

Awesome, keep practicing.

1 Like