PROGRAM TO CHECK THE GIVEN NUMBER IS PALINDROME OR NOT
// prg to illustrate given number is palindrome or not
#include<stdio.h>
void main()
{
int n,r,rev=0,temp;
printf("enter any number:");
scanf("%d",&n);
temp=n;
while(n != 0)
{
r = n % 10;
n = n / 10;
rev=rev *10 +r;
}
if( temp == rev )
printf("%d is a palandrome \n",temp);
else
printf("%d is not a palandrome \n",temp);
}
output:
// prg to illustrate given number is palindrome or not
#include<stdio.h>
void main()
{
int n,r,rev=0,temp;
printf("enter any number:");
scanf("%d",&n);
temp=n;
while(n != 0)
{
r = n % 10;
n = n / 10;
rev=rev *10 +r;
}
if( temp == rev )
printf("%d is a palandrome \n",temp);
else
printf("%d is not a palandrome \n",temp);
}
output:
No comments:
Post a Comment