C# program for finding how many numbers are devidable by 5 in give range
Posted
by
user1639735
on Stack Overflow
See other posts from Stack Overflow
or by user1639735
Published on 2012-11-04T22:44:45Z
Indexed on
2012/11/04
23:00 UTC
Read the original article
Hit count: 209
c#
My task 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.
Console.Write("Enter min: ");
int min = int.Parse(Console.ReadLine());
Console.Write("Enter max: ");
int max = int.Parse(Console.ReadLine());
Console.WriteLine("The numbers devidable by 5 without remainder from {0} to {1} are: ",min,max);
for (int i = min; i <= max; i++)
{
if (i % 5 == 0)
{
Console.WriteLine(i);
}
}
This prints out the numbers that are devidable by 5 in the range...How do I count how many are there and print the count in the console? Thanks.
© Stack Overflow or respective owner