Problems in the Code with if command.
Hello everybody. I have difficulties with a C code
Code:
#include<stdio.h>
int main()
{
int primes[4];
int counter=1;
int start=3;
int prime;
int i;
primes[0]=2;
printf("2");
while(counter<4)
{
prime=1;
for(i=0; i<counter&′ i++)
if((!start%primes[i]))
prime=0; // here is my problem
if(prime) // How if works ???? prime = 0
{
printf("\n%d",start);
primes[counter++]=start;
}
start++;
}
printf("\n");
return 0;
}
I pose/put the value 0 in prime variable and after that I put it into if
how works??? From theory I knew that if command stops to work when find a zero value. And now the prime is 0!!!!!
Thank in advance. :)