...

/

Challenge: The Nearest Power of 2

Challenge: The Nearest Power of 2

Find the nearest power of 2 for a number that has been input.

Task

Write a program that takes a positive number (num) and finds the power of 22 nearest to that number. The program stores the resulting value to pwr.

Access this course and 40+ top-rated courses and projects.