Episode 12: Checking Palindrome Number

Share this content:

Explanation: What is a palindrome? Palindrome means a number is same even when it is reversed. Just for example 121. It remains same even if we reverse it.

So first is to reverse the number and then compare both the number whether it is same or not. Reversing number I told you in previous episode Link 

code:

#include <stdio.h>
#include <conio.h>

void main()
{
int n,rev=0,orginal;

printf(“Enter the Number: “);
scanf(“%d”,&n);
orginal=n;
while(n>0)
{
rev = (rev*10)+(n%10);
n=n/10;
}

if(orginal==rev)
{
printf(“\nNumber is palindrome”);
}
else
{
printf(“\nNumber is not palindrome”);
}

getch();
}

Output:

Enter the Number: 1234

Number is not palindrome

Enter the Number: 121

Number is palindrome

Share this content:

Leave a Reply

Your email address will not be published. Required fields are marked *

TechGenBlog © 2017 | With ❤ From India