Friday, February 20, 2009

Write a C program to determine the given integer is Palindrome or not.

#include(stdio.h) // place this '<' & '>' instead of '(' & ')' before stdio.h
#include(conio.h)
void main( )
{
int no, rem, rev=0, temp;
clrscr( );
printf("Enter the required integer:");
scanf("%d", &no);
temp=no;
while(temp>0)
{
rem=temp%10;
rev=(10*rev)+rem;
temp=temp/10;
}
if(no==rev)
printf("\n%d is Palindrome number", no);
else
printf("\n%d is not a palindrome string", no);
getch();
}

Output:-
Enter the required number: 141
141 is palindrome number.

Note:- If u have any doubt regarding this program or logic, please feel free to contact me.

No comments:

Post a Comment