Exforsys
+ Reply to Thread
Results 1 to 3 of 3

palindrome

This is a discussion on palindrome within the C and C++ forums, part of the Programming Talk category; how to check if any given number is a palindrome or not... the number is entered from the user...

  1. #1
    ankit_golden is offline Junior Member Array
    Join Date
    Feb 2008
    Answers
    5

    Question palindrome

    how to check if any given number is a palindrome or not...
    the number is entered from the user


  2. #2
    lawrence is offline Junior Member Array
    Join Date
    Mar 2007
    Location
    coimbatore, india
    Answers
    21

    palindrome

    a = xxxxxxxxx;
    b = a;
    c = 0;

    while(b > 0)
    {
    c *= 10;
    c += b%10;
    b = b/10;
    }

    if(a == c)
    {
    'palindrome';
    }
    else
    {
    'not palindrome';
    }


  3. #3
    monuasthana is offline Junior Member Array
    Join Date
    Mar 2008
    Answers
    1

    palindrome

    Quote Originally Posted by ankit_golden View Post
    how to check if any given number is a palindrome or not...
    the number is entered from the user
    void main()
    {
    int n,d,sum=0,ori;
    printf("\nEnter any No. :");
    scanf("%d",&n);
    ori=n;
    while(n>=1)
    {
    d=n%10;
    n=n/10;
    sum=sum*10+d;
    }
    if(sum==ori)
    printf("\n given number is a palindrome.");
    else
    printf("\ngiven number is a not palindrome.");
    getch();
    }


    •    Sponsored Ads



Latest Article

Network Security Risk Assessment and Measurement

Read More...