CODE OF GEEKS


A PLATFORM TO LEARN | CODE | ACHIEVE


" Programming is the real test of your creativity,its all about how you turn ideas into codes. "



Connect :


THIS WEBSITE IS BEST VIEWED IN THE GOOGLE CHROME WEB BROWSER.



TO CHECK WHETHER A GIVEN NUMBER IS PALINDROME OR NOT IN C

Code

#include<stdio.h>
int main()
{
int n,i;
int rem=0,rev=0;
int num=0;
printf("ENTER THE NUMBER :");
scanf("%d",&n);
num=n;
while(num>0)
{
	rem=num%10;
	rev=rev*10+rem;
	num=num/10;
}
if(n==rev)
{
    printf("YES IT IS THE PALINDROME NUMBER\n");		
}
else
{
printf("NO IT IS NOT THE PALINDROME NUMBER\n");		
}
return 0; 
}

Output


ENTER THE NUMBER :23432
YES IT IS THE PALINDROME NUMBER


What we did - Our Approach


In this problem we have to check whether the given number is a Palindrome or not.
A palindromic number or numeral palindrome is a number that remains the same when its digits are reversed. Like 16461, for example, it is "symmetrical". Hence,it is quite clear that if a number is equal to its reversal then it is a palindrome number.

***FINDING THE REVERSE OF A NUMBER***
Let us consider an example :
Suppose we have to find the reverse of 535,we require three steps which needs to be performed under while loop condition (while n>0).
1 : Finding Remainder : rem=num%10
So, rem=535%10=5
2 : Finding Reverse : rev=rev*10+rem
So, rev=0+5
3 : Updating number : num=num/10;
So, num=53
But num>0, so we will perform above steps until 'num' gets equal to zero.After the last iteration we find rev=535.

***PALINDROME CHECKER***
Now we check whether the reverse of a number is equal to itself or not.In this case,535 is a Palindrome Number.

Join us :



CODE OF GEEKS

A Platform to LEARN | CODE | ACHIEVE

Connect :



INTERESTING READ FOR YOU :

SHARE:



For any Queries,suggestions,feel free to Mail us at :
codeofgeeks@gmail.com

For reporting any kind of copyright voilation,mail us at : cogcopyclaim@gmail.com

© copyright CODE OF GEEKS 2018