Skip to content

Instantly share code, notes, and snippets.

@MaxySpark
Last active September 3, 2016 22:52
Show Gist options
  • Save MaxySpark/727d8451d98d9c40003fd9674b90ab97 to your computer and use it in GitHub Desktop.
Save MaxySpark/727d8451d98d9c40003fd9674b90ab97 to your computer and use it in GitHub Desktop.
palindrome number function
int palindrome(int n) {
int a,rev=0;
a = n;
while(n!=0) {
rev = (rev*10) + (n%10);
n = n/10;
}
if(rev==a) {
return 1;
} else {
return 0;
}
}
int palindrome(int n) {
int a,rev=0;
a = n;
while(n!=0) {
rev = (rev*10) + (n%10);
n = n/10;
}
if(rev==a) {
return 1;
} else {
return 0;
}
}
public static int palindrome(int n) {
int a,rev=0;
a = n;
while(n!=0) {
rev = (rev*10) + (n%10);
n = n/10;
}
if(rev==a) {
return 1;
} else {
return 0;
}
}
function palindrome(n) {
var a,rev=0;
a = n;
while(n!=0) {
rev = (rev*10) + (n%10);
n = n/10;
}
if(rev==a) {
return 1;
} else {
return 0;
}
}
#include <stdio.h>
int palindrome(int n) {
int a,rev=0;
a = n;
while(n!=0) {
rev = (rev*10) + (n%10);
n = n/10;
}
if(rev==a) {
return 1;
} else {
return 0;
}
}
int main(void) {
int p,c;
printf("Enter The Number You Want To Check For Palindrome : ");
scanf("%d",&p);
c = palindrome(p);
if(c==0) {
printf("Not Pelindrome\n");
} else if(c==1) {
printf("Pelindrome\n");
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment