Kat H.

asked • 04/12/21

Log Switcher. Read in a number (double). Print the power of two that the number represents.

Read in a number (double). Print the power of two that the number represents.


C++11 added a log base 2 function, but you can also just use the formula: power = log(number) / log(2) where log is the natural logarithm function.


Code:


#include <iostream>


Don't forget the math library!!!


using namespace std;


int main()

{

//YOUR_CODE

}

1 Expert Answer

By:

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.