# REVERSE A NO WITHOUT USING mod

Page 1 of 1

## 5 Replies - 8055 Views - Last Post: 07 September 2007 - 11:09 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'https://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=32801&amp;s=7a08f5a4a5057096f24e696d60ebb00e&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 sandeepnerli

Reputation: 0
• 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

• g+ + -o drink whiskey.cpp

Reputation: 250
• Posts: 13,507
• Joined: 12-July 02

## Re: REVERSE A NO WITHOUT USING mod

Posted 06 September 2007 - 11:33 AM

What language?

### #3 sandeepnerli

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

## Re: REVERSE A NO WITHOUT USING mod

Posted 06 September 2007 - 11:55 AM

in c..

### #4 no2pencil

• Professor Snuggly Pants

Reputation: 6635
• Posts: 30,902
• 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.

### #5 Xing

Reputation: 19
• 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

### #6 born2c0de

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

Reputation: 187
• Posts: 4,673
• 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.