here the 2nd if that is,if(prime) is not part of the for loop.

correct oneCode:#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&&prime; 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; }