WAP in C to Check Whether a Number is Palindrome or Not?

#include<stdio.h>
#include<conio.h>
int main()
{
int n,s=0,r,t;
clrscr();
printf(“Enter an integer: “);
scanf(“%d”, &n);
t=n;
while( n!=0 )
{
r = n%10;
s = s*10 + r;
n = n/10;
}
// palindrome if orignalInteger(t) and reversedInteger(s) are equal
if (t == s)
printf(“%d is a palindrome.”, t);
else
printf(“%d is not a palindrome.”, t);
getch();
return(0);
}

Output:-

palin

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s