Recursive function to print numbers in reverse

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • laith kawar
    New Member
    • Sep 2007
    • 1

    Recursive function to print numbers in reverse

    Hey everybody,
    i need a function that takes a number and prints the reverse.

    for example input 321, output 123
  • Meetee
    Recognized Expert Contributor
    • Dec 2006
    • 928

    #2
    Originally posted by laith kawar
    Hey everybody,
    i need a function that takes a number and prints the reverse.

    for example input 321, output 123
    What have you tried for this problem? I can just give you the algorithm for this.

    1) Devide the number by 100 and take the integer part in a variable. Take the fractional part and again devide it by 10. Thus you will get 3 numbers individually

    2) now rearrange those number by multiplying and adding them.

    Tip: 321 = 300 + 20 +1

    Regards

    Comment

    • ashitpro
      Recognized Expert Contributor
      • Aug 2007
      • 542

      #3
      don't spoonfeed, it's bad for the learning process

      Comment

      Working...