1 min read

Checking Given Integer is Palindrome or Not

According to wikipedia.org  A Palindrome is a word, phrase, number, or
other sequence of characters which reads the same backward or forward.
Allowances may be made for adjustments to capital letters, punctuation,
and word dividers. So I am going to to show how to check whether a given integer is  Palindrome or Not using C.Environment:
OS- Linux (kubuntu 16.04)
Compiler – GCC
IDE -Codeblock

include <stdio.h>
/*
To check if a string is a palindrome or not,
a string needs to be compared with the reverse of itself.
*/

int main(){
int n;
int reverseno = 0;
int remainder;
int originalno;

printf("Please enter a integer :");
scanf("%d",&n);
originalno = n;

while(n!=0){
remainder= n%10;
reverseno= reverseno *10 +remainder;
n/=10;
}

if(originalno == reverseno)
printf("%d is a palindrome.", originalno);
else
printf("%d is not a palindrome.", originalno);
return 0;
}

Screen shot :

You can do it palindrome  check in any language like PHP, Javascript, Python, Ruby , Java , just change the code little bit .

0 0 votes
Article Rating
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

2 Comments
Oldest
Newest Most Voted
Ramesh K

Thanks for sharing this informative information…You may also refer….
How to migrate from a typical HTML4 page to a typical HTML5 page.
http://www.s4techno.com/blog/2016/08/30/html5-migration/

annikaromy

The website is looking bit flashy and it catches the visitors eyes. A design is pretty simple .