-
Make variables called:
total_number_of_dots
and set its value to the number entered by the end user.bit_value
and set its value to 1. Double its value until it is bigger thantotal_number_of_dots
.bits
and set its value to 0. Every time that you doublebit_value
you need to add a new bit for storing the number (increase the value ofbits
by 1).
-
Use a while loop to repeat the lines as long as
total_number_of_dots
is greater than or equal tobit_value
. Display the value ofbits
as the output. -
Set the variable
bit_value
to 1 and double it until it is bigger thantotal_number_of_dots
. Every time that you doublebit_value
you need to add a new bit for storing the number. Use a while loop to repeat these steps until the condition is no longer true In this challenge you need to repeat the blocks whiletotal_number_of_dots
is greater than or equal tobit_value
. -
Test your program with some values on the boundaries (for example number 31 would need 5 bits and 32 needs 6 bits).