Advertisement
Guest User

Untitled

a guest
May 21st, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.77 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace advanced_loops
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.                      
  14.             while (true)
  15.             {
  16.                 Console.WriteLine("Enter a number in range [1...100]");
  17.                 int num = int.Parse(Console.ReadLine());
  18.                
  19.  
  20.                 if (num >= 1 && num <= 100)
  21.                 {
  22.                     Console.WriteLine($"The number is: {num}");
  23.                     break;
  24.                 }
  25.                 else
  26.                 {
  27.                     Console.WriteLine("Invalid number!");
  28.                 }
  29.             }
  30.            
  31.         }
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement