Ok one last fixup....
for(b=2;b<=N-1;b++)
is the same as
for(b = 2; b < N; b++)
if N == 5 then N - 1 = 4 so <= makes it exit on 4, returning false on 5. b < N will return true for values 0 .. 4 and false on 5 ...
It may not seem like much of a difference for relatively small values of N but the <= N -1 adds in a bit of extra code -- suptracting 1 from N and doing 2 comparisons every time-- that will amount to a performance difference on larger values... It could make a difference of minutes if you asked for the first 10,000,000 prime numbers.