1st. Check if its prime 2nd. If prime, reverse digits 3rd. check if its reverse is prime.. if yes also , print -- number and reverse number are palindromic numbers My code below is not working correctly.. Can you fix it to complete the task? #include #include using namespace std; int reverse(int num){ int temp=0,r; while(num>=1)    { r=num%10;    temp=temp*10+r; num=num/10;    } return temp; } bool isPrime(int num){ int rem=num%2; int div=3; while(rem!=0&&div<=sqrt(num)){ rem=num%div; div+=2; } if(rem!=0) return true; else return false; } int main (void){ int num=0; int temp=0; for (int num = 1000; num<10000; num++) { if(isPrime(num)) temp=reverse(num); if(isPrime(temp)){ cout< } else{ } } return 0;

Programming with Microsoft Visual Basic 2017
8th Edition
ISBN:9781337102124
Author:Diane Zak
Publisher:Diane Zak
Chapter5: The Repetition Structure
Section: Chapter Questions
Problem 1MQ8
icon
Related questions
Question

HELP WITH CODE!! I am trying to run a loop to display all 4 digit palindromic prime numbers. I need to

1st. Check if its prime

2nd. If prime, reverse digits

3rd. check if its reverse is prime.. if yes also , print -- number and reverse number are palindromic numbers

My code below is not working correctly.. Can you fix it to complete the task?

#include
#include
using namespace std;
int reverse(int num){
int temp=0,r;
while(num>=1)   
{
r=num%10;   
temp=temp*10+r;
num=num/10;   
}
return temp;
}

bool isPrime(int num){
int rem=num%2;
int div=3;
while(rem!=0&&div<=sqrt(num)){
rem=num%div;
div+=2;
}
if(rem!=0)
return true;
else
return false;
}


int main (void){
int num=0;
int temp=0;
for (int num = 1000; num<10000; num++)
{
if(isPrime(num))
temp=reverse(num);
if(isPrime(temp)){
cout< }

else{

}
}
return 0;
}

Expert Solution
steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Program on Numbers
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning