# quotient in loop

Page 1 of 1

## 2 Replies - 394 Views - Last Post: 29 January 2013 - 11:24 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=310137&amp;s=46c34161f05ff991df21ed17b7f9f225&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 Johan113

Reputation: 0
• Posts: 12
• Joined: 17-January 12

# quotient in loop

Posted 29 January 2013 - 11:06 AM

hello

this is a homework so please dont give me the answer to the problem.

```            int num1, num2;
for (num1 = 1; num1 <= 101; num1++)
{
for (num2 = 1; num2 <= 101; num2++)
{
if (num1 / num2 == 5)
Console.WriteLine(num1 + "/" + num2);
}
}
```

this is what i have so far. the 2 numbers that com up first is right but then its relly get wrong. I want it to be every time the 2 numbers have the quotient of 5 the 2 numbers will com up on the screen. like if 10/2 = 5 then the 10/5 will com up.

Is This A Good Question/Topic? 0

## Replies To: quotient in loop

### #2 Skydiver

• Code herder

Reputation: 4246
• Posts: 13,582
• Joined: 05-May 12

## Re: quotient in loop

Posted 29 January 2013 - 11:20 AM

What do you mean by "but then its really get wrong"? The code seems to be doing exactly what you told it to do.

Remember that when you divide one integer by another integer, you get an integer result. So 11 / 2 == 5. Perhaps you are looking for the cases when the remainder is zero, and when the quotient is 5. In that case you'll probably want to use the modulus (%) operator as well.

This post has been edited by Skydiver: 29 January 2013 - 11:21 AM

### #3 Johan113

Reputation: 0
• Posts: 12
• Joined: 17-January 12

## Re: quotient in loop

Posted 29 January 2013 - 11:24 AM

i fix it