Friday, November 11, 2011

How to check a number palindrome or not in C


How to check a number palindrome or not in C
#include<stdio.h>
void main(){
    int n,r,sum=0,temp;

    printf("Please enter a number: ");
    scanf("%d",&n);

    temp=n;
    while(n){
         r=n%10;
         n=n/10;
         sum=sum*10+r;
    }
    if(temp==sum)
         printf("%d is a palindrome number",temp);
    else
         printf("%d is not a palindrome number",temp);
}

0 comments:

Post a Comment

You are most welcome for making comments here. I will consider your view and will reply you soon.