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.
using namespace std;
start= new int[n];
stop= new int[n];
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.