The problem I'm having is that when you put in the two numbers the answer is just prime.... nothing. I cannot figure this out ive been working on this forever, can someone please god just tell me how to fix this without encrypted "hints".
#include <iostream>
#include <cmath>
using namespace std;
// FUNCTION PROTOTYPE FOR read_range
void read_range(int& imin, int& imax);
// FUNCTION PROTOTYPE FOR is_prime
bool is_prime(int& k);
// DO NOT MODIFY THE MAIN ROUTINE IN ANY WAY
int main()
{
int imin(0), imax(0);
// Read in range
read_range(imin, imax);
// Print prime numbers
cout << "Primes:";
for (int k = imin; k <= imax; k++)
{
if (is_prime(k))
{
cout << " " << k;
}
}
cout << endl;
return 0;
}
// DEFINE FUNCTION read_range() HERE:
void read_range(int& imax, int& imin)
{
cout<<"Enter minimum and maximum:";
cin>>imin>>imax;
while(imin>imax)
{
cout<<"Error, Minimum must be less then maximum"<<endl;
cout<<"Enter minimum and maximum:";
cin>> imin>>imax;
}
while((imin<2 || imax<2))
{
cout<<"Error, Minimum and maximum must be at least 2"<<endl;
cout<<"Enter minimum and maximum:";
cin>> imin>>imax;
}
}
// DEFINE FUNCTION is_prime() HERE:
bool is_prime(int& k)
{
for(int i=2; i<=(k-1); i++)
{
if (k%i !=0)
true;
}
}