grach

Number in range 1 to 100

Jul 19th, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.07 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 Number_in_Range_1to100
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int num = int.Parse(Console.ReadLine());
  14.  
  15.             while (num < 1 || num > 100)
  16.             {
  17.                 Console.WriteLine("Invalid number!");
  18.                 num = int.Parse(Console.ReadLine());
  19.             }
  20.             Console.WriteLine("The number is: {0}", num);
  21.         }
  22.     }
  23. }
  24.  
  25.  
  26.  
  27. /*   //Pesho , 123,  да се изпълни програмата само , ако потребителя въведе правилните данни
  28. string name = Console.ReadLine();
  29. string pass = Console.ReadLine();
  30.  
  31. while (name!="Pesho" || pass != "123" )
  32. {
  33.     Console.WriteLine("Invalid input.");
  34.     name = Console.ReadLine(); //ако не въведем отново стойността ще получим безкраен цуикъл
  35.     pass = Console.ReadLine();
  36. }
  37. Console.WriteLine("Welkome");
  38.  
  39. }
  40. }
  41. }
  42. */
Advertisement
Add Comment
Please, Sign In to add comment