this time i tried to make it with the help of list.....
here is my code.....
include
include
include
struct list
{
long int val;
struct list *next;
};
struct list ptr,c,*k;
int main()
{
int test;
long int i,j,m,n,s;
ptr=(struct list*)malloc(sizeof(struct list *));
scanf("%d",&test);
if(test<=10)
{
for(i=0;i<test;i++)
{
scanf("%ld%ld",&m,&n);
if((n-m)<=100000)
{
ptr->val=0;
ptr->next=NULL;
k=ptr;
if((m>=1)&&(m<=1000000000)&&(n>=1)&&(n<=1000000000))
{
for(j=2;j<(n+1);j++)
{
c=(struct list *)malloc(sizeof(struct list *));
c->val=j;
c->next=NULL;
ptr->next=c;
ptr=ptr->next;
}
c=(struct list *)malloc(sizeof(struct list *));
c=k;
c=c->next;
for(;c->val<=sqrt(n);c=c->next)
{
ptr=k;
ptr=ptr->next;
while(ptr->next!=NULL)
{
if(ptr!=NULL)
{
if((ptr->next->val)%(c->val)==0)
{
ptr->next=ptr->next->next;
}
if(ptr->next!=NULL)
{
ptr=ptr->next;
}
}
}
}
ptr=k;
while(ptr->val<=m)
{ptr=ptr->next;}
while(ptr!=NULL)
{
printf("%ld\n",ptr->val);
ptr=ptr->next;
}
}
}
printf("\n");
}
}
return 0;
}
but this code still gives run time error SIGSEGV in worst case in ideone....
i dont know where the problem is....
please help....