Advertisement
DaniPasteBin

Untitled

Feb 19th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.51 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 _06.Number_in_Range_ot1do100
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             //Console.Write("Enter a number in the range [1 ... 100]: ");
  14.             int num = int.Parse(Console.ReadLine());
  15.  
  16.  
  17.             while (num < 1 || num > 100)
  18.             {
  19.  
  20.                 Console.WriteLine("Invalid number");
  21.                 Console.Write("Enter a number in the range [1 ... 100]: ");
  22.                 num = int.Parse(Console.ReadLine());
  23.             }
  24.  
  25.             Console.WriteLine($"The number is: {num}");
  26.  
  27.             //вариант първи
  28.             /*if (num >= 1 && num <= 100)
  29.             {
  30.                 Console.WriteLine($"The number is: {num}");
  31.             }
  32.             else
  33.             {
  34.                 Console.WriteLine("Invalid number");
  35.             }*/
  36.  
  37.            
  38.  
  39.  
  40.  
  41.             /*for (int i = 0; i <= 100; i++)
  42.             {
  43.                 Console.Write("Enter a number in the range [1 ... 100]: ");
  44.                 int num = int.Parse(Console.ReadLine());
  45.                 if (num % 2 == 0 && num >= 0 && num <= 100)
  46.                 {
  47.                     Console.WriteLine($"The number is: {num}");
  48.                 }
  49.                 else
  50.                 {
  51.                     Console.WriteLine("Invalid number");
  52.  
  53.                 }
  54.                    
  55.  
  56.             }*/
  57.  
  58.         }
  59.     }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement