Bit Flipping Programming Exercise in C
I think your code does not exactly what the comment wants. In line:

x |= (y &amp; ~(0 &lt;&lt; n)) &lt;&lt; p;


0 &lt;&lt; n is 0. If you want n rightmost bits of y you may use a mask like (1&lt;&lt;n)-1 (which is n 1 bits).
Now on your code style, when you are coding a bit manipulating task, you'd better do it completely with bitwise operators (at least use other functions very few). Here in this code, using log and pow can be avoided. If you want to get number of bits in an integer type, you can use sizeof, like below:

size_t s = sizeof(int) &lt;&lt; 3;


here &lt;&lt; 3 is equal to * 8, because each byte definitely has 8 bits (it works on integer types of any size, just replace int with any other type like short or long long).

Now instead of using pow(2, s) you can write 1 &lt;&lt; s :)

And about your printing, you can replace s%4 with s&amp;3 (think about it). And I prefer shifting down mask instead of shifting up x (here  it doesn't make any difference, but when you work with signed values it does, because sign will be preserved in left shifts). And for reducing number of lines for printing, you may use for loop.