# Prime Number Generation SIGABRT problem C++

Please somebody tell me why the code stated below is generating SIGABRT error. The code is for generating prime numbers between two given numbers which are taken as input by the user.

``````

#include<iostream>
using namespace std;
int main()
{
int n;
cin>>n;
int *start;
int *stop;
start= new int[n];
stop= new int[n];
int i;
for(i=0;i<n;i++)
{
cin>>start[n]>>stop[n];
}
int j,k;
for(j=0;j<n;j++)
{
for(i=start[j];i<=stop[j];i++)
{
for(k=1;k<=(i/2);k++)
{
if(i%k==0)
{
break;
}
else if(k==i/2)
{
cout<<i<<"\n";
}
}
}
cout<<"\n";
}
delete[] start;
delete[] stop;
return 0;
}

[\code]``````
```May be the limit on n is quite large! You can atmost make an array of 10^8 size for online judges.
That too in the heap memory ie. outside the main function. Making an array of size of even 10^7 in the main function can lead to runtime errors.
Try not to use more than of the order 10^8 elements for the array.. :)

In the question you are attempting the upper limit is 10^9
You can make an array of that size. Thats why SIGABRT error which means you exceeded the memory limit.

Lemme know if this helps! :)```

I appreciate your help, but i think it’s not related to memory space. I found the error although!

On line 21, the value of K should be initialized from ‘2’ instead of ‘1’ as every number is divisible by 1 so no output will be generated in this case.