text: Highest power of 2 less than or equal to given number | C ++ program to find highest power of 2 smaller than or equal to n . ; Driver code
code: #include <bits/stdc++.h> NEW_LINE using namespace std ; int highestPowerof2 ( int n ) { int p = ( int ) log2 ( n ) ; return ( int ) pow ( 2 , p ) ; } int main ( ) { int n = 10 ; cout << highestPowerof2 ( n ) ; return 0 ; }