Python Compiler
import math num = int(input("Enter a Decimal Number: ")); copyNum = num; arr = [0]*50 i = -1 while(copyNum != 0): i += 1 arr[i] = copyNum % 2 copyNum = math.floor(copyNum / 2) print("Binary number of %d (decimal) is " % num, end="") for j in range(i, -1, -1): print(arr[j], end="")
OUTPUT
Enter a Decimal Number: 50
Binary number of 50 (decimal) is 110010
×

Save as Private