REVERSE A NO WITHOUT USING mod

To reverse a number without using mod functions

Page 1 of 1

5 Replies - 5839 Views - Last Post: 07 September 2007 - 11:09 PM Rate Topic: -----

#1 sandeepnerli  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 08-June 07

REVERSE A NO WITHOUT USING mod

Posted 06 September 2007 - 11:17 AM

How do u reverse a number without using mod funtion(%). is there an efficient code for it other than the above...
Is This A Good Question/Topic? 0
  • +

Replies To: REVERSE A NO WITHOUT USING mod

#2 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,507
  • Joined: 12-July 02

Re: REVERSE A NO WITHOUT USING mod

Posted 06 September 2007 - 11:33 AM

What language?
Was This Post Helpful? 0
  • +
  • -

#3 sandeepnerli  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 08-June 07

Re: REVERSE A NO WITHOUT USING mod

Posted 06 September 2007 - 11:55 AM

in c..
Was This Post Helpful? 0
  • +
  • -

#4 no2pencil  Icon User is offline

  • Admiral Fancy Pants
  • member icon

Reputation: 5364
  • View blog
  • Posts: 27,325
  • Joined: 10-May 07

Re: REVERSE A NO WITHOUT USING mod

Posted 06 September 2007 - 12:56 PM

I would use sprintf to dump it into an array, then get the size of the number (in digits) & reverse the order of the array, starting with highest.
Was This Post Helpful? 0
  • +
  • -

#5 Xing  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 19
  • View blog
  • Posts: 725
  • Joined: 22-July 06

Re: REVERSE A NO WITHOUT USING mod

Posted 06 September 2007 - 07:21 PM

It's always a good idea to search the forum/snippets before posting a question.
http://www.dreaminco...pet.php?sid=935
http://www.dreaminco...pet.php?sid=526
Was This Post Helpful? 0
  • +
  • -

#6 born2c0de  Icon User is offline

  • printf("I'm a %XR",195936478);
  • member icon

Reputation: 180
  • View blog
  • Posts: 4,667
  • Joined: 26-November 04

Re: REVERSE A NO WITHOUT USING mod

Posted 07 September 2007 - 11:09 PM

I guess he did, since both snippets use the mod operation.

If you can't use the mod operator '%', you can simulate it by using a pair of \ and - operations.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1