-
Make variables called:
total_number_of_dotsand set its value to the number entered by the end user.bit_valueand set its value to 1. Double its value until it is bigger thantotal_number_of_dots.bitsand set its value to 0. Every time that you doublebit_valueyou need to add a new bit for storing the number (increase the value ofbitsby 1).
-
Use a while loop to repeat the lines as long as
total_number_of_dotsis greater than or equal tobit_value. Display the value ofbitsas the output. -
Set the variable
bit_valueto 1 and double it until it is bigger thantotal_number_of_dots. Every time that you doublebit_valueyou 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_dotsis 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).