Emirp

having trouble


#include <iostream>
#include <iomanip>

using namespace std;

bool areYouPrime(int number);
int reverse(int num);

void main()
{
int count=0;

for(int number=10;count != 100;number++)
{
if(areYouPrime(number))
{

if(areYouPrime(reverse(number)))
{
count++;
cout << setw(6) << number;

if (count%10 == 0)
{
cout << endl;
}
}

}
}
}
// determine if input is a prime number
bool areYouPrime (int number)
{
bool response;
if (number%2 == 0 || number%3 == 0 || number%5 == 0 ||number%7 == 0 )
response=false;

else
response=true;
return response;
}
// switch prime number order
int reverse(int number)
{
int rev=0;

while(number > 0)
{
rev = rev * 10 + (number %10);
number = number/10;
}

return rev;
}

closed account (D1AqM4Gy)
-snip
Last edited on
Topic archived. No new replies allowed.