I cannot get this program to give me primes. It either gives me all the numbers in a range or just the odds.
#include <iostream.h> //for cout and cin
#include <math.h> //for sqrt
int main () //not float main
{
int a, b, c, d; // range and test values
cout << "Enter two integers "; //prompt for integers
cin >> a >> b; //user inputs range
for (c=a; c<=b; c++) //loop to cycle through range
{
for(d=1; d<=sqrt(c); d++) //loop to test for primes
{
if(c%d==0) //checking for even divisibility
break; //continue to next integer
else
cout << " " << c; break; //print prime and continue
}
} //explain what the output indicates
cout << " are the prime numbers in the range " << a << " to " << b << endl;