Advertisement
kuruku

NumbersInGivenInterval

Apr 19th, 2014
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.71 KB | None | 0 0
  1. using System;
  2.  
  3. //Write a program that reads two positive integer numbers and prints how many numbers p exist
  4. //between them such that the reminder of the division by 5 is 0.
  5.  
  6. class NumbersInGivenInterval
  7. {
  8.     static void Main()
  9.     {
  10.         Console.Write("Start: ");
  11.         int start = int.Parse(Console.ReadLine());
  12.         Console.Write("End: ");
  13.         int end = int.Parse(Console.ReadLine());
  14.         int counter = 0;
  15.         for (int i = start; i <= end; i++)
  16.         {
  17.             if (i % 5 == 0)
  18.             {
  19.                 Console.Write("{0}, ",i);
  20.                 counter++;
  21.             }
  22.         }
  23.         Console.WriteLine();
  24.         Console.WriteLine("p = {0}", counter);
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement