How to find Palindrome Number in C

webcamEasy steps for finding the Palindrome Numbers

#include <stdio.h>
#include <conio.h>
void main() {
int num,r,sum=0;
int temp;
clrscr();
//starting of the program
printf(“Enter the number from user=”);
scanf(“%d”,&num);
temp=num;

while(num>0){   //starting of the loop
r=num%10;
sum=sum*10+r;
num=num/10;
}

//here the value of num will be zero at last of iteration of loop

//compare the sum value with temp variable which holds the real value of num variable.
if(sum==temp){
printf(“The given number is palindrome”);
}
else{
printf(“The given number isn’t palindrome”);
}

getch();
}

Output of the program:

For First Run:

Enter the number from user=122
The given number isn’t palindrome
For Second run:

Enter the number from user=1221
The given number is palindrome

starIf you have any questions, please feel free to write me

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *