Monday, 28 July 2014

Write a program to enter a no. and check it is palindrome prime or not.

#include<stdio.h>
#include<conio.h>
void main()
{
        int i, n, on, rem, revno=0, k=1;
        clrscr();
printf(“Enter any no. : ”);
scanf(“%d”, &n);
for(i=2;i<=n/2;i++)
{
if(n%i==0)
                {
                                k=0;
                                break;
}
}
on=n;
while(n>0)
{
                rem=n%10;
                revno=(revno*10)+rem;
                n=n/10;
}
if(revno==on && k==1)
printf(“%d is a palindrome prime no.”, on);
else
printf(“%d is not a palindrome prime no.”, on);
getch();
}
OUTPUT :
Enter any no. : 131

131 is a palindrome prime no.

No comments:

Post a Comment