Challenge: The Nearest Power of 2
Explore how to create a C# program that calculates the nearest power of two to an input number. Understand the use of for and while loops along with conditional statements, and practice applying these concepts to solve programming challenges.
Task
Write a program that takes a positive number (num) and finds the power of nearest to that number. The program stores the resulting value to pwr.
If there are two candidate values, display the smaller one. For example, ...