Program for Checking whether the given number is Palindrome or not
Palindrome means a number which remains same if positions of its digits is reversed i.e., 1221
#include<stdio.h>
#include<conio.h>
void main()
{
int n,digit,rev=0,num;
printf("enter the number");
scanf("%d",&num);
n=num;
do
{
digit=num%10;
rev=rev*10+digit;
num/=10;
}while(num!=0);
printf("reverse number is=%d\n",rev);
if(n==rev)
{
printf("number is palindrome");
}
else
{
printf("number is not palindrome") ;
}
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int n,digit,rev=0,num;
printf("enter the number");
scanf("%d",&num);
n=num;
do
{
digit=num%10;
rev=rev*10+digit;
num/=10;
}while(num!=0);
printf("reverse number is=%d\n",rev);
if(n==rev)
{
printf("number is palindrome");
}
else
{
printf("number is not palindrome") ;
}
getch();
}
This comment has been removed by the author.
ReplyDeletenic
ReplyDelete