pupesko

SoftUni - 4.11* Numbers Divided by 5

Oct 2nd, 2015
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.89 KB | None | 0 0
  1. //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.
  2.  
  3. using System;
  4.  
  5. class NumbersDev5
  6. {
  7.     static void Main()
  8.     {
  9.         Console.Write("Enter Start number = ");
  10.         string one = Console.ReadLine();
  11.         int start = int.Parse(one);
  12.  
  13.         Console.Write("Enter End number = ");
  14.         string second = Console.ReadLine();
  15.         int end = int.Parse(second);
  16.  
  17.         int p = 0;
  18.  
  19.         if (start <= 0 || end < start)
  20.         {
  21.             Console.WriteLine("Enter positive numbers, greater than 0.");
  22.         }
  23.         else
  24.         {
  25.             for (int i = start; i <= end; i++)
  26.             {
  27.                 if (i % 5 == 0)
  28.                 {
  29.                     p++;
  30.                 }
  31.             }
  32.             Console.WriteLine("p = " + p);
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment