elements (integers).Store them all with 1(TRUE) at the beginning.Now,follow SOE to cross out multiples starting with

multiples of 2.Now it is emphasized to take 2 pointers one for storing the address of first element of array and the second for last element.

CONSTRAINT:use only pointer arithmetic.Use of subscript to make it easy is not allowed.Use just 0 & 999 subscript to acquire the addresses of first and last element.

The upper limit of SOE is 1000.

At last I have displayed all the prime numbers(not crossed out).

Problem:Had I seen an error or garbage output.I would still be like(Fine-What now?).But here I am getting a DON'T SEND

(probably some crash)error.Can you tell me the cause of this error.I have seen this before too.I have always wondered -why this out of all possibilities.

Here is the code:

#include<stdio.h> void sieve_of_eratosthenes(void); int main() { sieve_of_eratosthenes(); return 0; } void sieve_of_eratosthenes(void) { int record[1000],i,n; int *p1=&record[0],*p2=&record[999]; //Initialization while(p1<=p2) { *(p1++)=1; //All have been assumed as true } p1=&record[0]; p1+=2; for(i=2;i<=1000;) { if(*p1==0) { i++; continue; } n=i; while(p1<=p2) { p1+=n; *p1=0; } p1=&record[0]+ (++i); } p1=&record[2]; for(i=2;i<=1000;i++) { if(*p1==1) { printf("%d\t",i); } if(i%4==0) printf("\n"); } }

If you need any other info. ,let me know.