Search C Program

Loading...

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

No comments:

Post a Comment