Social Icons

Wednesday, 19 March 2014

C Program check a number is palindrome or not

#include<stdio.h>
#include<conio.h>
main()
{
clrscr();
{
int n,num,d,rev=0;
printf("\n Enter a number : ");
scanf("%d",&n);
num=n;
do
{
d=n%10;
rev=(rev*10)+d;
n=n/10;
}
while(n!=0);

printf("\n Reverse of the given number is : %d",rev);
if(num==rev)
printf("\n\n\t Number is Palindrome");
else
printf("\n\n\t Number is not Palindrome");
}
getch();
}

                                                            OUTPUT

No comments:

Post a Comment