-
Make variables called:
originaland set its value to the input number given by the end user.decimal_valueand set its value tooriginal(this is so we can still use the original number later)bit_valueand set its value to 1. Find the smallest bit value which is larger than thedecimal_numberby doubling value ofbit_valuewhile it is smaller or equal todecimal_number.binary_numberis a string variable and stores the binary cards needed (‘1’ for dots showing and ‘0’ for not showing).
-
Set the variable
bit_valueto 1 and find the smallestbit_valuewhich is larger thandecimal_numberby multiplyingbit_valueby 2 while it is smaller or equal todecimal_number. You can do this by using a while loop. -
Now divide the
bit_valueby 2 and check ifdecimal_numberis greater than or equal tobit_value. If it is, add ‘1’ to the stringbinary_numberand subtractbit_valuefromdecimal_number. If not, add ‘0’ to the stringbinary_number. Repeat whilebit_valueis greater than 1. Display the value ofbinary_numberas the output.