Skip to main content

Posts

Showing posts from December, 2013

wap in c to print the prime numbers between two numbers using sieve method.

To know about sieve method go to -- http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes #include<stdio.h> #include<math.h> int main() { int count; long int n,m,i,j,t=1; while(t--) { printf("enter the numbers between you want to print the prime numbers"); scanf("%d %d",&m,&n); if(m==1||m==2)     printf("%d\n",2); if(m%2==0) m=m+1; for(i=m;i<=n;i=i+2) { count=0; for(j=3;j<=sqrt(i);j=j+2) if(i%j==0) {count++;break;} if(count==0&&i!=1) printf("%d\n",i); } printf("\n"); } return(0); }