Checking if a number is a power of 2 without loops
Use only necessary #includes. The &lt;stdlib.h&gt; is not needed here.
Give your operators some breathing space. ((nr&amp;(nr-1))==0) is next to unreadable.
Separate logic from presentation:

int is_power_of_two(int nr)
{
    return nr &amp; (nr - 1) == 0;
}


is much more reusable.
Care about corner cases. Your code claims that 0 is a power of two (which it is not).