Hi everyone, I have wirte a programme to display the Palindromic prime, i.e 2,3,5,7,11,101,131,151..........
but I don't know what's wrong with my code, it can only display the number up to 11 and then no response. Could yuou help me to check out what's wrong? thank you so much.
Here is the code:
-----------------------------------------------------------------------------------------
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int a;
cin>>a;
int prime=2;
int i=1;
int start;
int end;
while(i<=a)
{
bool isprime = true;
start=prime;
while(start>=10)
{
start=prime/10;
}
end=prime%10;
cout<<"("<<start<<")"<<"("<<end<<")"<<endl;
for(int j=2; j<prime; j++)
{
if((prime%j==0)||(start!=end))
{
isprime = false;
break;
}
}
if(isprime)
{
if(i%10==0)
{
cout<<setw(8)<<prime<<endl;
}
else
{
cout<<setw(8)<<prime;
}
i++;
}
prime++;
}
cout<<endl;
system("pause");
return 0;
}