Program
code
#include
<stdio.h>
#include
<conio.h>
void
main()
{
long
int temp=0, number=0, reverse=0;
clrscr();
printf(“Please
input a whole number to find out whether it is a palindrome.\n”);
scanf(“%ld”,&number);
for
(temp=number;temp>0;temp=temp/10)
reverse=(reverse*10)+(temp%10);
if
(number==reverse)
printf(“%ld
is palindrome.\n”,number);
else
printf(“%ld
is not a palindrome.\n”,number);
getch();
}
Example
of output
Please
input a whole number to find out whether it is a palindrome.
1221
1221
is palindrome.
No comments:
Post a Comment
Please write here, your opinion about this C program