Thread: "writing reverse of a number" i need your help

  1. #1
    Registered User
    Join Date
    Aug 2006
    Posts
    2

    Question "writing reverse of a number" i need your help

    Hi everybody;
    i need a program that writes reverse of a number for ex;
    if i enter 42 output will be 24 and, for 789 it will be 987.
    We don't know how many digits will user type...
    Thanks... Have a nice day...

  2. #2
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    Hint. 24 / 10 = 2 remainder 4.

    http://en.wikipedia.org/wiki/Modulo_operation

  3. #3
    The Richness... Richie T's Avatar
    Join Date
    Jan 2006
    Location
    Ireland
    Posts
    469
    Or you could read as a string and print out the string in reverse - also allows you
    to easily validate the input - use fgets to read a string if you don't know how to
    already. Tonto's solution is the most common answer to this question, so
    whichever suits you.
    No No's:
    fflush (stdin); gets (); void main ();


    Goodies:
    Example of fgets (); The FAQ, C/C++ Reference


    My Gear:
    OS - Windows XP
    IDE - MS Visual C++ 2008 Express Edition


    ASCII stupid question, get a stupid ANSI

  4. #4
    Registered User
    Join Date
    Aug 2006
    Posts
    2
    Tonto and Richie T. thanks for your attention. I hope i will write true code after your help...
    Thanks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem with my reverse function and its output!
    By Matus in forum C Programming
    Replies: 4
    Last Post: 04-29-2008, 08:33 PM
  2. a reverse function
    By AngKar in forum C Programming
    Replies: 20
    Last Post: 04-27-2006, 10:35 PM
  3. Using reverse iterators in algorithms
    By 0rion in forum C++ Programming
    Replies: 1
    Last Post: 02-27-2006, 03:19 AM
  4. gethostbyaddr() reverse lookups failing (???)
    By Uncle Rico in forum C Programming
    Replies: 9
    Last Post: 08-19-2005, 09:22 AM
  5. Replies: 7
    Last Post: 03-18-2003, 03:32 PM