Computer Science, asked by amisha7396, 11 months ago

write a program to enter an integer number and check whether it is a pal prime or not.where the number should be a prime number as well as palindrome.


amisha7396: please give the answer its urgent

Answers

Answered by atd01
1
Solution in C++ =>

#include <iostream>
#include <math.h>
using namespace std;

bool palindrome(int n) {
int i,r,s=0;
for(i=n;i!=0;i=i/10) {
r=i%10;
s=s*10+r;
}
if(s==n)
return true;
else
return false;
}

bool prime(int n) {
int i;
if(n==1)
return false;
else {
for(i=2;i<=sqrt(n);i++) {
if(n%i==0)
return false;
}
}
return true;
}

int main() {
int n;
cin>>n;
if(palindrome(n)) {
if(prime(n))
cout<<"yes";
else
cout<<"no";
}
else
cout<<"no";
return 0;
}

amisha7396: please give the solution by using scanner
atd01: Do you mean in Java ?
Answered by maheepnarayanpandey9
0

Answer:

Explanation:

Where the first community technical telecentre was opened

Similar questions