-
Make variables called:
originaland set its value to the input number given by the end user.numberand set its value to original (this is so that you can display the original number later)bit_valueand set its value to 32.cardsis a variable and stores the binary cards needed (‘B’ for black cards and ‘W’ for white cards).
-
Now divide
bit_valueby 2 and check ifnumberis greater than or equal tobit_value. If it is, add ‘W’ to stringcardsand subtractbit_valuefromnumber. If not, add ‘B’ to string variablecards. Repeat untilbit_valueis equal to 1, using a while loop whilebit_value> 1 Display the value ofcardsas the output. -
Test your program with some values on the boundaries (for example test it with numbers 0 and 31).