diff --git a/Bit manipulation/checking_power_of_2.cpp b/Bit manipulation/checking_power_of_2.cpp new file mode 100644 index 0000000..741e65e --- /dev/null +++ b/Bit manipulation/checking_power_of_2.cpp @@ -0,0 +1,15 @@ +#include +#include + +using namespace std; + +/* + Program to find whether a given number is power of 2. +*/ + +bool checkPowerOf2(int n) +{ + if((n & (n-1)) == 0) + return true; + return false; +} \ No newline at end of file