Hello I'm trying to create a program that reads a number(which is the amount of pairs) then you input the pairs and then for each pair it prints the prime numbers between the 2 numbers of the pair.Here's the code:
#include <iostream>
using namespace std;
class Prime {
int x,y;
public:
void count(int,int);
};
void Prime::count(int k,int l)
{
int f=k%2;
int g=k%3;
int h=k%5;
do
{
if (f==0)
break;
else if (g==0)
break;
else if (h==0)
cout << k;
k++;
} while (k<=l);
}
int main(void)
{
int * primes;
int n,i;
int a,b;
cout << "Give the amount of numbers you wish to try:"<< endl;
cin >> n;
primes = new int[n];
for (i=0;i<=(n-1);i++)
{
cout << "Give the 2 numbers:" << endl;
cin >> a >> b;
Prime primes[i];
primes[i].count(a,b);
}
}
unfortunately after inputting the pairs the program stops.Any advice?Thanks in advance!