Below is the program that I have written for printing the next power of 2 for a given number.
The code mostly uses the bitwise operations in c/c++.
int main ()
if(!((num != 1) && (num&(num-1))))
printf("%d is already a power of two.\n",num);
printf("%d is next number power of 2.\n",num*2);