Ok, I've narrowed my issue down to the "modulus," not the "for ()" loop. I'm trying to make a program to have the computer make a list of prime numbers. If I substitute 3 into int "tester," next to the "remainder" equation, it works fine. Why can't I use a variable in this loop "int remainder=x % tester?"
Be CAREFUL, this app will crash, but should compile fine.
#include <iostream>
using namespace std;
bool isitprime(int x)
{
for (int tester=0; tester<x; tester++)
{
int remainder=x % tester;
if (remainder==0)
{
cout<<"yea";
return 1;
break;
}
}
return 0;
}
int main()
{
int y;
int q;
cin>>y;
cout<<isitprime(y);