To Check a Palindrome number
Wednesday, 23 November 2016
Programming in 'C'
Question-
Who invented the palindrome in C language?
Answer-
Sotades the obscene of Maronea (3rd century BC) is credited with inventing the palindrome.
To check a palindrome number:-
#include<stdio.h>
#include<conio.h>
void main()
{
int n, reverse=0,temp;
printf("enter a number to check if it is a palindrome or not:");
scanf("%d",&n);
temp=n;
while(temp!=0)
{
reverse=reverse*10;
reverse=reverse+temp%10;
temp=temp/10
}
if(n==reverse)
printf("%d is a palindrome",n);
else
printf("%d is not a palindrome",n);
getch();
}
Output:-
enter a number to check if it is a palindrome or not:
141
141 is a palindrome