so this program suppose to find number of primes (number that divides only by itself) in the given range. I know the problem is with my "for" statement.. i just cant find it :( Thank you
#include <iostream>
using namespace std;
int main()
{
int intStart, intEnd, intPrime;
intPrime=0;
cout << "Enter starting number: ";
cin >> intStart;
cout << "Enter ending number: ";
cin >> intEnd;
int DivideBy = 2;
for (int Number=intStart; Number<=intEnd; Number++){
while (Number%DivideBy!=0){
DivideBy++;
if (DivideBy==Number){
intPrime++; }
}
}
cout <<"Number of primes in range: "<<intPrime<<endl;
system("pause");
return (0);
}