How to count If statements?

Page 1 of 1

2 Replies - 864 Views - Last Post: 27 April 2013 - 05:10 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=319675&amp;s=6bf0807f30f5a0851dc60458d86f3351&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

#1 unholycode

Reputation: 0
• Posts: 5
• Joined: 11-March 13

How to count If statements?

Posted 27 April 2013 - 04:21 AM

First I will start that this is home work.The homework is "Write a program that reads two positive integer numbers and prints how many numbers p exist between them such that the reminder of the division by 5 is 0 (inclusive). Example: p(17,25) = 2.".My question is how to count the right statements that are divided by 5.I searched around and can't find anything that will count and print how much numbers will be printed.I don't know how to formulate the If or there is another way as presented in the following example - (17,25) = 2.

```using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _04.TwoInsDev5
{
class TwoInsDev5
{
static void Main(string[] args)
{
Console.WriteLine("Enter two positive integer nubmers:");
if (a > 0 && b > 0)
{
for (int i = a; i <= b; i++)
{
if (i % 5 == 0)
{

}

}
}
else if (a <= 0 || b <= 0)
{
}
}
}
}

```

Is This A Good Question/Topic? 0

Replies To: How to count If statements?

#2 andrewsw

• I'm not here to twist your niblets

Reputation: 4444
• Posts: 16,260
• Joined: 12-December 12

Re: How to count If statements?

Posted 27 April 2013 - 04:28 AM

Can't find anything that will count? . A variable will count if you start it at 0 and keep adding 1 to it. You could name that variable p.

#3 darek9576

• D.I.C Lover

Reputation: 200
• Posts: 1,700
• Joined: 13-March 10

Re: How to count If statements?

Posted 27 April 2013 - 05:10 AM

You must take care of the scenario when a > b. Maybe have an if-statement to determine which number is greater.