I understand the sieve of eratosthenes on paper but in c code I find it hard to get the logic of using booleans like 1 and 0 to filter primes. In the code below, the algorithm for which is detailed in kochan's programming in c, I find it hard to break down the code and find how booleans help?

Code:

#include<stdio.h>
int main (void)
{
int P[151], i, j;// Also why is p initialized 1 more than n?
int n = 150;
for (i = 2; i <= n; ++i)
P[i] = 1;
i = 2;
while (i <= n) {
if (P[i] == 1)// how does this identify a prime?
printf("%i ", i);
j = 1;
while (i * j <= n) {
P[i * j] = 0;
++j; //why are non- primes accumulated?
}

Can anyone please help me analyze what's going on here. Also any suggestions on the code's optimization will be greatly useful for me in future.