Last active
September 3, 2016 22:52
-
-
Save MaxySpark/727d8451d98d9c40003fd9674b90ab97 to your computer and use it in GitHub Desktop.
palindrome number function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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