Advertisement
kisyova

Numbers in Interval Dividable by Given Number

Mar 30th, 2014
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2.  
  3. class NumbersiIntervalDividableGiven
  4. {
  5.     static void Main()
  6.     {
  7.         Console.Write("Give a start: ");
  8.         uint start = uint.Parse(Console.ReadLine());
  9.         Console.Write("Give an end: ");
  10.         uint end = uint.Parse(Console.ReadLine());
  11.         int counter = 0;
  12.         uint i = 0;
  13.  
  14.         if (start != 0 && end != 0)
  15.         {
  16.             for (i = start; i <= end; i++)
  17.             {
  18.                 if(i % 5 == 0)
  19.                 {
  20.                     counter++;
  21.                 }
  22.             }
  23.             Console.WriteLine("The numbers dividable by 5 between {0} and {1} is/are {2} : {3}",start,end,counter,i);
  24.         }
  25.         else
  26.         {
  27.             Console.WriteLine("Wrong input!!!");
  28.         }
  29.    
  30.         }
  31.        
  32.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement