i want to print prime no's between 2 and 200,

in te code i've written, it is also printing 127 which is not prime, don't know why because the variable c should be greater than 2 for 127

in te code i've written, it is also printing 127 which is not prime, don't know why because the variable c should be greater than 2 for 127

Code: c

#include<conio.h>

#include<stdio.h>

#include<math.h>

int main()

{

int c,i,num;

clrscr();

for (num=2;num<=200;num++)

{

c=0;

for(i=1;i<=num;i++)

{

if(num%i==0) c=c+1; //checking if num is divisible by i

}

if(c==2) //for prime no's c will be 2

printf("%d ",num); //num is div by 1 and num itself

}

getch();

return 0;

}