Search C Program

Palindrome number using for loop

/* Palindrome number using for loop */

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

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

7 comments:

  1. explanation in comment section might made it best but still good effort

    ReplyDelete
  2. its not working for 121 and other small digits,kindly help

    ReplyDelete
  3. Not working for 121

    ReplyDelete