# integer divison without / or %

Page 1 of 1

## 1 Replies - 3083 Views - Last Post: 13 August 2007 - 08:10 AMRate 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=31624&amp;s=1dfe6e2601dbb3514505b87bd87b0a06&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 dianenacario

Reputation: 0
• Posts: 5
• Joined: 08-August 07

# integer divison without / or %

Posted 13 August 2007 - 06:07 AM

int[] Divide(int divisor, int dividend)
{
int remainder = dividend;
int quotient = 0;

while (remainder >= divisor)
{
remainder -= divisor;
quotient++;
}

return new int[] { quotient, remainder };
}

[b] i am trying to do a divison program..
i should not use " / or %"
i should only use a while loop or a for loop.

i wanted it to be like this,

output of program: any number % any number = quotient
input dividend: dividend
input divisor: divisor
quotient: quotient
remainder: if there is a remainder[i]

Is This A Good Question/Topic? 0

## Replies To: integer divison without / or %

### #2 csmanoj

Reputation: 11
• Posts: 150
• Joined: 06-August 07

## Re: integer divison without / or %

Posted 13 August 2007 - 08:10 AM

And could you please put your code inside code blocks so its clearer?

Page 1 of 1

 .related ul { list-style-type: circle; font-size: 12px; font-weight: bold; } .related li { margin-bottom: 5px; background-position: left 7px !important; margin-left: -35px; } .related h2 { font-size: 18px; font-weight: bold; } .related a { color: blue; }