Find all the prime numbers between a given pair of numbers.
Numbers should be read in from an input file called "numbers.txt" and find all the prime numbers between them. Store the prime numbers in an array, then sort the array from greatest
to least. Display the array before and after the sort.
I'm stuck on how to put the prime numbers into an array.
The input file has the numbers 1 & 100.
Here's what I have so far.
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream fin;
fin.open("numbers.txt");
int num1,
num2;
fin >> num1 >> num2;
for (int i = num1; i <= num2; i++)
{
for (int j = 2; j <= i; j++)
{
if (!(i%j)&&(i!=j))
{
break;
}
if (j==i)
{
cout << i << " ";
}
}
}