Advertisement
dimov

Untitled

Dec 30th, 2012
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.75 KB | None | 0 0
  1. sing System;
  2. using System.Text;
  3.  
  4. class DivisionByFive
  5. {
  6.     static void Main()
  7.     {
  8.         uint p = 0;
  9.         Console.Write("please write down positive int a = ");
  10.         uint a = uint.Parse(Console.ReadLine());
  11.         Console.Write("please write down positive int b = ");
  12.         uint b = uint.Parse(Console.ReadLine());
  13.         if (a > b)
  14.         {
  15.             a = a + b;
  16.             b = (a - b);
  17.             a = (a - b);
  18.         }
  19.         for (uint i=a;i<=b;i++)
  20.         {
  21.             uint k = i % 5;
  22.             if (k == 0)
  23.             {
  24.                 p++;
  25.             }
  26.         }
  27.         Console.WriteLine("the numbers between {0} and {1} that can be divided by 5 with reminder = 0, are 'p'={2}", a, b, p);
  28.        
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement