I don't think it is possible to handle such large inputs with int as a data type. int is of 4 bytes. So its range is 2147483648, which is less than 3000000000. Long is as big as int, so using int is of no use (atleast this is what sizeof() on my computer says). If your program is working fine with smaller inputs, be calm.
Maybe your computer can't assign that much of memory for the array you are making. Mine can only assign 250000 ints. If you want to use larger numbers and you have Visual C++, you can use __int64. It is 8 bytes long.
Its not just space you need to take care of. Spped is also a concern.
My computer has a 3 Ghz intel i5 processor and 4 GB RAM. I too made a prime number utility once. It statically assigns memory (at the beginning of the program). In that memory, I store prime numbers. Whenever the computer needs prime numbers, it updates the array with new prime numbers.
For eg. I entered lower limit 2 and upper limit 1000000. It took 33.232 seconds to give the answer as 78498. But when I entered the same limits again, it took only 0.014 seconds as it generated prime numbers upto 1000000 during the 1st operation and the second time it only counted the number of primes in the limits (using a binary search-like algorithm). So, you can expect very large limits to take a lots and lots of time (maybe hours)
For the input (100,2) you are getting 0 as the program takes lower limit as 100. To prevent this, check if the 1st argument is larger than the 2nd and swap them if this is true.
These are the values I get for the experiment:
If you need to verify in the future the number of primes between 2 numbers, use www.wolframalpha.com. In the text box, enter what you want to find out.
I might be able to find the bug in your program if I look very closely, but that will take a lot of time as I haven't written this code. You can find the bug yourself if you use the debugger and the watch windows. If you use Visual C++, I can help you. The debugger is a tool which lets you execute your program step by step, so you can see what's going on. Watch windows let you see the value of variables. But beware, use it as a last resort or you will get addicted and wouldn't be able to code without.
Most of your outputs are one more than my outputs. But the word 'most' introduces a problem as now you can't just subtract 1 from the answer!