-
Make variables called:
decimal_number
and set its value to the input number given by the end user.bit_value
and set its value to 1. Find the smallest bit value which is larger thandecimal_number
by doubling value ofbit_value
until it is bigger than thedecimal_number
(by using a while loop whilebit_value
is less than or equal todecimal_number
).
-
Set the variable
bit_value
to 1 and find the smallestbit_value
which is larger thandecimal_number
by multiplyingbit_value
by 2 until it is larger thandecimal number
. You can do this by using a while loop. -
Now divide the
bit_value
by 2 and check ifdecimal_number
is greater than or equal tobit_value
. If it is, print "high" for a high note and subtractbit_value
fromdecimal_number
. If not, print "low" for a low note. Repeat untilbit_value
is equal to 1 (by using a while loop whilebit_value
is greater than 1)