Reputation: 11
The problem is with this for loop:
for (int i = 0; i < n; i++);
{
a = y & 1;
y = y >> 1;
b = a | b;
b = b << 1;
}
you see i have set n to 4 so the compiler should've went four times through the loop, but it only goes through once (I added a "printf" to print 'i' and it prints 4). Why is i being set to 4 instead of zero?
ps I'm using visual studio 2013
Upvotes: 0
Views: 50
Reputation: 87959
for (int i = 0; i < n; i++);
^
Extra semi-colon. Easy mistake to make.
Upvotes: 3