C program to check whether a number is palindrome or not

Preview
You must first complete for statement in c language | Nesting of for in c language before viewing this Lesson

C program to check whether a number is palindrome or not.

#include<stdio.h>
#include<conio.h>
void main()
{
int m,n,r,t;
printf(“\nEnter a number:=”);
scanf(“%d”,&n); //n=1221
t=n; //t=1221
r=0;
while(n>0)
{
m=n%10;
r=r*10+m;
n=n/10;
} //r=1221
if(t==r)
printf(“\nNumber is palendrome”);
else
printf(“\nNumber is not palendrome”);
getch();
}

Best Books of Computer Science

Back to: C Programming Language