Friday, October 1, 2010

C program to print all prime numbers between 1 and 100.

int main()
{
int i,j,n=0;
for(i=2;i<=100;i++)
{
for(j=1;j<=i;j++)
{
if(i%j==0)
{
n++;
}
}
if(n==2)
printf("%d\n",i);
n=0;
}
getch();
}

No comments:

Post a Comment

Google+ Followers