To check number is palindrome or not
Output:
Enter the number to check whether it is palindrome or not12321
Number is palindrome 12321 = 12321
Code:
#include<stdio.h>
int main()
{
int rem,div,n,temp,sum =0;
printf("\n Enter the number to check whether it is palindrome or not");
scanf("%d",&n);
temp = n;
while(n!=0)
{
rem = n%10;
div = n/10;
sum = sum*10 + rem;
n = div;
}
if(sum == temp)
{
printf("\n Number is palindrome %d = %d ",temp,sum);
}
else
{
printf("\n Number is not palindrome %d != %d",temp,sum);
}
}
Output:
Enter the number to check whether it is palindrome or not12321
Number is palindrome 12321 = 12321
Code:
#include<stdio.h>
int main()
{
int rem,div,n,temp,sum =0;
printf("\n Enter the number to check whether it is palindrome or not");
scanf("%d",&n);
temp = n;
while(n!=0)
{
rem = n%10;
div = n/10;
sum = sum*10 + rem;
n = div;
}
if(sum == temp)
{
printf("\n Number is palindrome %d = %d ",temp,sum);
}
else
{
printf("\n Number is not palindrome %d != %d",temp,sum);
}
}
Its good
ReplyDelete