Advertisement
Guest User

Untitled

a guest
Jul 2nd, 2016
565
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.80 KB | None | 0 0
  1. using System;
  2.  
  3. class Program
  4. {
  5.     static void Main(string[] args)
  6.     {
  7.         Console.Write("Еnter a number in the range [1...100]: ");
  8.         int n = int.Parse(Console.ReadLine()); // Прочитаме числото
  9.  
  10.         // В while-цикъла ще се влезе само в случай, че числото n не е в диапазона [1 ... 100]
  11.         while (n<1||n>100)
  12.         {
  13.             Console.WriteLine("Invalid number!");
  14.             Console.Write("Еnter a number in the range [1...100]: ");
  15.             n = int.Parse(Console.ReadLine()); // Прочитаме числото отново, тъй като не е било в диапазона [1 ... 100]
  16.         }
  17.  
  18.         Console.WriteLine("The number is: {0}", n); // Изписваме числото
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement