SHARE
TWEET

1_to_100_adv_loops

rado84 Jul 2nd, 2016 183 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2.  
  3. namespace WHILE_OneToHundred
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             Console.WriteLine("Enter a number in the range [1...100]: ");
  10.             int num = int.Parse(Console.ReadLine());
  11.  
  12.  
  13.             if (num < 1 || num > 100)
  14.             {
  15.                 Console.WriteLine("Invalid number!");
  16.                 Console.WriteLine("Enter a number in the range [1...100]: ");
  17.                 Console.ReadLine();
  18.             }
  19.  
  20.             while (true)
  21.             {
  22.                 if (num >= 1 && num <= 100)
  23.                 {
  24.                     Console.WriteLine("The number is: " + num);
  25.                 }
  26.                 break;
  27.             }
  28.         }
  29.     }
  30. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top