Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Help with this question Please.

  1. #1
    Join Date
    Dec 2004
    Posts
    91
    Rep Power
    0

    Default Help with this question Please.

    A palindrome is a word, phrase, number or other sequence of units that can be read the same way in either direction. Example, 54145 or 12321. Write a program that accepts a 5 digit number then use a function to determine if the number entered is a palindrome or not.
    "God gives every bird its food, but He does not throw it into its nest"

  2. #2
    Join Date
    Apr 2003
    Posts
    13,269
    Rep Power
    34

    Default

    Dude, this is simple. How do you determine if a number is a palindrome?
    The first 2 digits and the last 2 digits (when turned around) are the same.
    So just do a check for that and you're good.
    Simple!
    "The best software is the one that fits your needs." - A_A

    Virus free since: date unknown
    Anti-virus free since: August 2008

  3. #3
    Join Date
    Jan 2009
    Posts
    2,404
    Rep Power
    0

    Default

    Quote Originally Posted by Arch_Angel View Post
    Dude, this is simple. How do you determine if a number is a palindrome?
    The first 2 digits and the last 2 digits (when turned around) are the same.
    So just do a check for that and you're good.
    Simple!
    Actually, you would say x digits so as not to limit it to 5 units. To make it more flexible, reverse the string and compare the original with the reversed version...
    Rooted OnePlus 2 64GB Ed, Android 5.1.1 OxygenOS ; on teifin' AT&T's network; Rooted ASUS Transformer TF101 w/ dock, Android 5.1 KatKiss; Laptop: ASUS X550C, 2.0GHzx2, 8GB, 512GB SSD, Kubuntu 15.10;
    Facebook page: Skeleville Technology Solutions

  4. #4
    Join Date
    Apr 2003
    Posts
    13,269
    Rep Power
    34

    Default

    Quote Originally Posted by Skele Drew View Post
    Actually, you would say x digits so as not to limit it to 5 units. To make it more flexible, reverse the string and compare the original with the reversed version...
    Well the question asked for 5 digits. I guess you could always accommodate for more than 5.
    "The best software is the one that fits your needs." - A_A

    Virus free since: date unknown
    Anti-virus free since: August 2008

  5. #5
    Join Date
    Aug 2002
    Posts
    6,223
    Rep Power
    0

    Default

    The trick is reversing the number. A number like 45154 is actually 4 x 10,000 + 5 x 1000, etc... One way to do it would be to convert the number to text and use the last digit as the first in the new variable, etc.
    .
    PC - Ubuntu 15.04 64bit Desktop
    HP Pav G60-236US 3GB RAM Laptop, Ubuntu 15.04 64bit and Win7 Home

    "So Daddy, how come you telling me stealing not right when YOU copying DVDs? How come? How Come?"


    RIP Ramesh ...

  6. #6
    Join Date
    Dec 2004
    Posts
    91
    Rep Power
    0

    Default

    I just started C, thanks for the pointers.
    "God gives every bird its food, but He does not throw it into its nest"

  7. #7
    Yung_Jah Guest

    Default

    You see A_A....something will always seem easy to you....but not us. So bear with us. I am having a challenging catching up also.

  8. #8
    Join Date
    Apr 2005
    Posts
    1,545
    Rep Power
    0

    Default

    Not only is the programming language hard to you, it seems so is the English language...






    I kid i kid....I kno its a typo.....

  9. #9
    Join Date
    Dec 2007
    Posts
    151
    Rep Power
    0

    Default

    Quote Originally Posted by crisis View Post
    Not only is the programming language hard to you, it seems so is the English language...






    I kid i kid....I kno its a typo.....
    Crisis comes here and calls out the Ultimate Techie....she's got balls...er....ovaries.
    U go girl
    CCNA looking for an opportunity

  10. #10
    Join Date
    Jan 2009
    Posts
    2,404
    Rep Power
    0

    Default

    Quote Originally Posted by kevon View Post
    Crisis comes here and calls out the Ultimate Techie....she's got balls...er....ovaries.
    U go girl
    Well she has been here a long time before him, though not active ...
    Rooted OnePlus 2 64GB Ed, Android 5.1.1 OxygenOS ; on teifin' AT&T's network; Rooted ASUS Transformer TF101 w/ dock, Android 5.1 KatKiss; Laptop: ASUS X550C, 2.0GHzx2, 8GB, 512GB SSD, Kubuntu 15.10;
    Facebook page: Skeleville Technology Solutions

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •