Search C Program | nimishsoft@gmail.com

Palindrome number using while loop

/* Palindrome number using while loop */

#include<stdio.h>
int main()
{
    int a, t, s;
    printf("Enter value of a: ");
    scanf("%d",&a);
    s = 0;
    t = a;
    while(a > 0)
    {
        s = s*10;
        s = s + (a%10);
        a = a / 10;
    }
    if(t == s)
        printf("Palindrome");
    else
        printf("Not Palindrome");
    return 0;
}

Related Post:
Palindrome number using for loop
http://cbasicprogram.blogspot.in/2012/03/palindrome-number-using-for-loop.html

1 comment: