The following C Program code checks whether the entered number is a palindrome or not.
SOURCE CODE
SOURCE CODE
This file contains hidden or 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 main() | |
{ | |
int n,rev=0,copy; | |
printf("Enter the number to check: "); | |
scanf("%d",&n); | |
copy=n; | |
while(n!=0) | |
{ | |
rev=(rev*10)+(n%10); | |
n=n/10; | |
} | |
if(rev==copy) | |
{ | |
printf("The number is a palindrome"); | |
} | |
else | |
{ | |
printf("It is not a palindrome"); | |
} | |
getch(); | |
return(0); | |
} |
Comments
Post a Comment